115 lines
3.7 KiB
CMake
115 lines
3.7 KiB
CMake
cmake_minimum_required(VERSION 4.0)
|
|
|
|
project(stonehearth_like_sim VERSION 0.1.0 LANGUAGES C CXX)
|
|
|
|
if(NOT WIN32)
|
|
message(FATAL_ERROR "Stonehearth-like Simulation Engine requires a Windows target.")
|
|
endif()
|
|
|
|
include(CTest)
|
|
if(BUILD_TESTING AND (NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16))
|
|
message(FATAL_ERROR "The reflection test suites need GCC 16 or later. Set BUILD_TESTING=OFF to build the game alone.")
|
|
endif()
|
|
|
|
include(FetchContent)
|
|
FetchContent_Declare(void_library
|
|
GIT_REPOSITORY https://git.faumaray.com/Void/Library
|
|
GIT_TAG 7b0fea6095f603f9e1904f66dfdc7752f4be4792
|
|
SYSTEM
|
|
EXCLUDE_FROM_ALL
|
|
)
|
|
|
|
function(add_void_library)
|
|
set(BUILD_SHARED_LIBS OFF)
|
|
set(VOID_ENABLE_TESTING OFF)
|
|
set(VOID_ENABLE_BENCHMARKS OFF)
|
|
set(VOID_ENABLED_MODULES Binary Core)
|
|
if(BUILD_TESTING)
|
|
list(APPEND VOID_ENABLED_MODULES Testing)
|
|
endif()
|
|
FetchContent_MakeAvailable(void_library)
|
|
endfunction()
|
|
add_void_library()
|
|
|
|
if(BUILD_TESTING AND NOT VOID_HAS_CXX26_REFLECTION)
|
|
message(FATAL_ERROR "The reflection test suites need working C++26 reflection support.")
|
|
endif()
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
add_library(settlement_core
|
|
engine/src/first_colony.cpp
|
|
engine/src/worker_pool.cpp
|
|
engine/src/world.cpp
|
|
engine/src/world_save.cpp
|
|
)
|
|
|
|
target_include_directories(settlement_core
|
|
PUBLIC
|
|
${CMAKE_CURRENT_SOURCE_DIR}/engine/include
|
|
)
|
|
|
|
target_compile_features(settlement_core PUBLIC cxx_std_20)
|
|
target_link_libraries(settlement_core
|
|
PUBLIC Threads::Threads
|
|
PRIVATE Void::Binary Void::Core
|
|
)
|
|
|
|
if(MSVC)
|
|
target_compile_options(settlement_core PRIVATE /W4 /permissive-)
|
|
else()
|
|
target_compile_options(settlement_core PRIVATE -Wall -Wextra -Wpedantic -Wconversion -Wshadow)
|
|
endif()
|
|
|
|
add_executable(settlement_sim
|
|
app/main.cpp
|
|
)
|
|
|
|
target_link_libraries(settlement_sim PRIVATE settlement_core)
|
|
|
|
add_executable(settlement_colony_benchmark benchmarks/colony.cpp)
|
|
target_link_libraries(settlement_colony_benchmark PRIVATE settlement_core)
|
|
|
|
add_library(settlement_lan STATIC
|
|
app/lan_session_win32.cpp
|
|
app/lan_wire.cpp
|
|
)
|
|
target_include_directories(settlement_lan PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/app)
|
|
target_link_libraries(settlement_lan
|
|
PUBLIC settlement_core
|
|
PRIVATE Void::Binary ws2_32 bcrypt iphlpapi
|
|
)
|
|
|
|
enable_language(RC)
|
|
add_executable(settlement_viewer WIN32
|
|
app/d3d_scene_win32.cpp
|
|
app/viewer_win32.cpp
|
|
app/house_icons.rc
|
|
)
|
|
target_link_libraries(settlement_viewer PRIVATE settlement_lan user32 gdi32 comctl32 comdlg32 d3d11 d3dcompiler)
|
|
if(MSVC)
|
|
target_compile_options(settlement_lan PRIVATE /W4 /permissive-)
|
|
target_compile_options(settlement_viewer PRIVATE $<$<COMPILE_LANGUAGE:CXX>:/W4;/permissive->)
|
|
else()
|
|
target_compile_options(settlement_lan PRIVATE -Wall -Wextra -Wpedantic -Wconversion -Wshadow)
|
|
target_link_options(settlement_viewer PRIVATE -municode)
|
|
target_compile_options(settlement_viewer PRIVATE
|
|
$<$<COMPILE_LANGUAGE:CXX>:-Wall;-Wextra;-Wpedantic;-Wconversion;-Wshadow>)
|
|
endif()
|
|
|
|
if(MSVC)
|
|
target_compile_options(settlement_sim PRIVATE /W4 /permissive-)
|
|
else()
|
|
target_compile_options(settlement_sim PRIVATE -Wall -Wextra -Wpedantic -Wconversion -Wshadow)
|
|
endif()
|
|
|
|
if(BUILD_TESTING)
|
|
add_executable(settlement_core_tests tests/core_tests.cpp tests/test_main.cpp)
|
|
target_link_libraries(settlement_core_tests PRIVATE settlement_core Void::Testing)
|
|
add_test(NAME settlement_core_tests COMMAND settlement_core_tests)
|
|
|
|
add_executable(settlement_lan_tests tests/lan_tests.cpp tests/test_main.cpp)
|
|
target_link_libraries(settlement_lan_tests PRIVATE settlement_lan Void::Testing)
|
|
add_test(NAME settlement_lan_tests COMMAND settlement_lan_tests)
|
|
endif()
|