Reduce Number Of CMake Projects

This commit is contained in:
TheBrokenRail
2023-10-30 22:49:56 -04:00
parent b7d8f767ed
commit 3b580eeed3
7 changed files with 30 additions and 74 deletions

View File

@@ -27,22 +27,30 @@ else()
endif()
# Build
add_executable(reminecraftpe
set(SOURCES
main.cpp
base/AppPlatform_sdl_base.cpp
)
if(EMSCRIPTEN)
list(APPEND SOURCES emscripten/AppPlatform_sdl.cpp)
else()
list(APPEND SOURCES desktop/AppPlatform_sdl.cpp)
endif()
add_executable(reminecraftpe ${SOURCES})
# Core
add_subdirectory(../../source source)
target_link_libraries(reminecraftpe reminecraftpe-core)
# SDL Base And Platform
add_subdirectory(base)
if(EMSCRIPTEN)
add_subdirectory(emscripten)
else()
add_subdirectory(desktop)
# OpenAL
add_subdirectory(../openal openal)
target_link_libraries(reminecraftpe reminecraftpe-openal)
# LibPNG (If Needed)
if(NOT EMSCRIPTEN)
find_package(PNG REQUIRED)
target_link_libraries(reminecraftpe PNG::PNG)
endif()
target_link_libraries(reminecraftpe reminecraftpe-sdl-platform)
# SDL
if(TARGET SDL2::SDL2main)
@@ -56,3 +64,10 @@ if(EMSCRIPTEN)
# Export Resize Function
target_link_options(reminecraftpe PRIVATE -sEXPORTED_FUNCTIONS=_main,_resize_from_js -sEXPORTED_RUNTIME_METHODS=ccall)
endif()
# Assets
if(EMSCRIPTEN)
target_link_options(reminecraftpe PRIVATE --use-preload-plugins --preload-file "${CMAKE_CURRENT_SOURCE_DIR}/../../game/assets@/assets")
else()
file(CREATE_LINK "${CMAKE_CURRENT_SOURCE_DIR}/../../game/assets" "${CMAKE_CURRENT_BINARY_DIR}/assets" SYMBOLIC)
endif()

View File

@@ -1,17 +0,0 @@
cmake_minimum_required(VERSION 3.16.0)
project(reminecraftpe-sdl-base)
# Build
add_library(reminecraftpe-sdl-base STATIC
AppPlatform_sdl_base.cpp
)
# Core
target_link_libraries(reminecraftpe-sdl-base reminecraftpe-core)
# Headers
target_include_directories(reminecraftpe-sdl-base PUBLIC .)
# OpenAL
add_subdirectory(../../openal openal)
target_link_libraries(reminecraftpe-sdl-base reminecraftpe-openal)

View File

@@ -2,7 +2,7 @@
#include <string>
#include "AppPlatform_sdl_base.hpp"
#include "../base/AppPlatform_sdl_base.hpp"
#define EM_BOOL bool
#define EM_TRUE true

View File

@@ -1,22 +0,0 @@
cmake_minimum_required(VERSION 3.16.0)
project(reminecraftpe-sdl-desktop)
# Build
add_library(reminecraftpe-sdl-platform STATIC
AppPlatform_sdl.cpp
)
# Core
target_link_libraries(reminecraftpe-sdl-platform reminecraftpe-core)
# SDL Base
target_link_libraries(reminecraftpe-sdl-platform reminecraftpe-sdl-base)
# Headers
target_include_directories(reminecraftpe-sdl-platform PUBLIC .)
# LibPNG
find_package(PNG REQUIRED)
target_link_libraries(reminecraftpe-sdl-platform PNG::PNG)
# Assets
file(CREATE_LINK "${CMAKE_SOURCE_DIR}/../../game/assets" "${CMAKE_BINARY_DIR}/assets" SYMBOLIC)

View File

@@ -5,7 +5,7 @@
#include <emscripten.h>
#include <emscripten/html5.h>
#include "AppPlatform_sdl_base.hpp"
#include "../base/AppPlatform_sdl_base.hpp"
class AppPlatform_sdl : public AppPlatform_sdl_base
{

View File

@@ -1,24 +0,0 @@
cmake_minimum_required(VERSION 3.16.0)
project(reminecraftpe-sdl-emscripten)
# Build
add_library(reminecraftpe-sdl-platform STATIC
AppPlatform_sdl.cpp
)
# Core
target_link_libraries(reminecraftpe-sdl-platform reminecraftpe-core)
# SDL Base
target_link_libraries(reminecraftpe-sdl-platform reminecraftpe-sdl-base)
# Headers
target_include_directories(reminecraftpe-sdl-platform PUBLIC .)
# WASM
target_link_options(reminecraftpe-sdl-platform PUBLIC -Wno-pthreads-mem-growth)
target_link_options(reminecraftpe-sdl-platform PUBLIC -sALLOW_MEMORY_GROWTH=1)
# Export Resize Function
target_link_options(reminecraftpe-sdl-platform PUBLIC -sEXPORTED_FUNCTIONS=_main,_resize_from_js -sEXPORTED_RUNTIME_METHODS=ccall)
# Assets
target_link_options(reminecraftpe-sdl-platform PUBLIC --use-preload-plugins --preload-file "${CMAKE_SOURCE_DIR}/../../game/assets@/assets")

View File

@@ -5,7 +5,11 @@
#include "thirdparty/GL/GL.hpp"
#include "client/app/App.hpp"
#include "AppPlatform_sdl.hpp"
#ifdef __EMSCRIPTEN__
#include "emscripten/AppPlatform_sdl.hpp"
#else
#include "desktop/AppPlatform_sdl.hpp"
#endif
typedef AppPlatform_sdl UsedAppPlatform;
#include "client/app/NinecraftApp.hpp"