-
Notifications
You must be signed in to change notification settings - Fork 105
/
CMakeLists.txt
137 lines (110 loc) · 4.12 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake" "${CMAKE_SOURCE_DIR}/cmake/find-modules" "${CMAKE_SOURCE_DIR}/cmake/dependencies-helpers")
cmake_policy(SET CMP0127 OLD)
include(FindPkgConfig)
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE)
include(CMakeDependentOption)
include(Macros)
include(FeatureSummary)
include(SourceFileUtils)
include(CMakeCM)
# create the cmake project
project(
# this will be the ${PROJECT_NAME}
Cytopia
# this will provide ${PROJECT_VERSION}
VERSION 0.4
# Description
DESCRIPTION "A city-building game"
# we are using C++
LANGUAGES CXX
)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
option(BUILD_TEST "Build Cytopia Tests" ON)
option(ENABLE_PHC "Use a Precompiled header for speeding up the build" ON)
option(ENABLE_DEBUG "Enable Debug (asserts and logs)" OFF)
option(ENABLE_ASAN "Enable Address Sanitizer" OFF)
option(ENABLE_UBSAN "Enable Undefined Behaviour Sanitizer" OFF)
option(ENABLE_TSAN "Enable Thread Sanitizer" OFF)
# setup paths
set(RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/")
set(LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/")
set(ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/")
set(EXECUTABLE_OUTPUT_PATH ${RUNTIME_OUTPUT_DIRECTORY})
set(LIBRARY_OUTPUT_PATH ${RUNTIME_OUTPUT_DIRECTORY})
if (WIN32)
# fix executable paths for windows
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${RUNTIME_OUTPUT_DIRECTORY})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${RUNTIME_OUTPUT_DIRECTORY})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${RUNTIME_OUTPUT_DIRECTORY})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${RUNTIME_OUTPUT_DIRECTORY})
endif ()
set(_include_directories "${CMAKE_CURRENT_SOURCE_DIR}/external/header_only")
set(_compile_definitions "")
set(_link_libraries "")
if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
list(APPEND _compile_definitions DEBUG)
endif ()
################################################################################
# Check for dependencies
################################################################################
include(DependenciesConfig)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
link_libraries(dbghelp.lib)
elseif (NOT APPLE AND NOT BUILD_ANDROID)
# Note: Apple supports std::filesystem with macOS10.15 and upwards.
# Needed for filesystem library
list(APPEND _link_libraries "stdc++fs")
endif ()
if (MINGW)
# need to link with mingw32 before SDL2
list(APPEND _link_libraries mingw32)
endif ()
# get linux distribution
if (UNIX AND NOT APPLE)
execute_process(COMMAND head -1 /etc/os-release OUTPUT_VARIABLE linux_distribution)
endif ()
# Configuration for packaging
include(CpackConfiguration)
# Compile options
include(CompileOptions)
message(STATUS "Building Project: ${PROJECT_NAME}")
message(STATUS "Build configuration: " ${CMAKE_BUILD_TYPE})
if (UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -fdiagnostics-color=always")
endif ()
# Include imgui project
add_subdirectory(external/imgui)
add_subdirectory(src)
if (BUILD_TEST)
include(CTest)
enable_testing()
add_subdirectory(tests)
endif (BUILD_TEST)
if (NOT BUILD_ANDROID)
# use Doxygen to generate the documentation
find_package(Doxygen)
endif ()
if (DOXYGEN_FOUND)
add_custom_target(
doc
COMMAND "${DOXYGEN_EXECUTABLE}" "${PROJECT_SOURCE_DIR}/Doxyfile"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
VERBATIM
)
endif ()
# copy itch.toml to build folder to install our prerequisits
if (WIN32)
if (CMAKE_SIZEOF_VOID_P EQUAL 8) ## 64 bit
message(STATUS "Using Win64 itch.toml file")
INSTALL(FILES ${CMAKE_SOURCE_DIR}/tools/itch/win64/.itch.toml
DESTINATION ${CMAKE_BINARY_DIR}/redist
)
elseif (CMAKE_SIZEOF_VOID_P EQUAL 4) ## 32 bit
message(STATUS "Using Win64 itch.toml file")
INSTALL(FILES ${CMAKE_SOURCE_DIR}/tools/itch/win32/.itch.toml
DESTINATION ${CMAKE_BINARY_DIR}/redist
)
endif ()
endif ()
feature_summary(WHAT ALL)