113 lines
3.1 KiB
CMake
113 lines
3.1 KiB
CMake
cmake_minimum_required(VERSION 3.18..3.27)
|
|
|
|
project(Redacted2DLevelLibrary
|
|
VERSION 1.2
|
|
LANGUAGES CXX)
|
|
|
|
if (PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
|
|
message(FATAL_ERROR "In-source builds are not allowed!")
|
|
endif()
|
|
|
|
set(CMAKE_BUILD_PARALLEL_LEVEL 8)
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE)
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
|
|
|
# Enable package managers
|
|
include(cmake/CPM.cmake)
|
|
|
|
file(GLOB_RECURSE FORMAT_HEADERS "include/Format/*.hpp")
|
|
file(GLOB_RECURSE FORMAT_SRC "src/Format/*.cpp" "src/Re2DLevelAPI.cpp")
|
|
file(GLOB_RECURSE EDITOR_SRC "src/Editor/*.cpp")
|
|
|
|
file(GLOB_RECURSE DEMOGAME_HEADERS "include/DemoGame/*.hpp")
|
|
file(GLOB_RECURSE DEMOGAME_SRC "src/DemoGame/*.cpp")
|
|
|
|
include_directories("include")
|
|
|
|
CPMAddPackage(NAME mcolor
|
|
URL https://git.redacted.cc/maxine/mcolor/archive/Release-1.zip)
|
|
|
|
CPMAddPackage(NAME jlog
|
|
URL https://git.redacted.cc/josh/jlog/archive/Prerelease-18.zip)
|
|
|
|
CPMAddPackage(NAME Event
|
|
URL https://git.redacted.cc/josh/Event/archive/Release-12.zip)
|
|
|
|
CPMAddPackage(NAME json
|
|
URL https://git.redacted.cc/josh/json/archive/Release-1.3.zip)
|
|
|
|
CPMAddPackage(NAME J3ML
|
|
URL https://git.redacted.cc/josh/j3ml/archive/3.4.5.zip)
|
|
|
|
CPMAddPackage(NAME ReWindow
|
|
URL https://git.redacted.cc/Redacted/ReWindow/archive/Prerelease-32.zip)
|
|
|
|
CPMAddPackage(NAME JGL
|
|
URL https://git.redacted.cc/josh/JGL/archive/Prerelease-58.zip)
|
|
|
|
CPMAddPackage(NAME JUI
|
|
URL https://git.redacted.cc/josh/ReJUI/archive/Prerelease-6.4.zip)
|
|
|
|
|
|
if (UNIX)
|
|
add_library(LevelFormat SHARED ${FORMAT_SRC})
|
|
add_library(Editor SHARED ${EDITOR_SRC})
|
|
endif()
|
|
|
|
if (WIN32)
|
|
ADD_LIBRARY(LevelFormat STATIC ${EDITOR_SRC})
|
|
ADD_LIBRARY(Editor STATIC ${EDITOR_SRC})
|
|
|
|
endif()
|
|
|
|
target_compile_definitions(LevelFormat PRIVATE Redacted2DLevelFormatVersion=1)
|
|
set_target_properties(LevelFormat PROPERTIES LINKER_LANGUAGE CXX)
|
|
set_target_properties(Editor PROPERTIES LINKER_LANGUAGE CXX)
|
|
|
|
set(CORE_DEPENDENCY_HEADERS
|
|
${J3ML_SOURCE_DIR}/include
|
|
${json_SOURCE_DIR}/include)
|
|
|
|
# Public Dependencies
|
|
target_include_directories(LevelFormat PUBLIC
|
|
${CORE_DEPENDENCY_HEADERS})
|
|
|
|
|
|
|
|
|
|
# TODO: Separate dependency packages such that only bare-minimum required is compiled with the just the lib.
|
|
target_include_directories(Editor PUBLIC
|
|
${Event_SOURCE_DIR}/include
|
|
${J3ML_SOURCE_DIR}/include
|
|
${jlog_SOURCE_DIR}/include
|
|
${JGL_SOURCE_DIR}/include
|
|
${ReWindow_SOURCE_DIR}/include
|
|
${JUI_SOURCE_DIR}/include
|
|
${mcolor_SOURCE_DIR}/include
|
|
)
|
|
|
|
target_link_libraries(LevelFormat PUBLIC Event J3ML json)
|
|
|
|
target_link_libraries(Editor PUBLIC LevelFormat jlog ReWindow JGL JUI mcolor)
|
|
|
|
|
|
|
|
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/assets/"
|
|
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/assets)
|
|
|
|
# Build Applications
|
|
|
|
add_executable(EditorApp apps/editor.cpp app.rc)
|
|
target_link_libraries(EditorApp PUBLIC Editor)
|
|
|
|
|
|
add_executable(DemoGame apps/game.cpp)
|
|
target_link_libraries(DemoGame PUBLIC LevelFormat)
|
|
|
|
add_executable(level_format_tests apps/tests.cpp)
|
|
target_link_libraries(level_format_tests PUBLIC LevelFormat)
|