-
Notifications
You must be signed in to change notification settings - Fork 10
/
CMakeLists.txt
169 lines (144 loc) · 5.56 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
cmake_minimum_required(VERSION 3.10)
project(ZenKit VERSION 1.3.0)
set(CMAKE_CXX_STANDARD 17)
option(ZK_BUILD_EXAMPLES "ZenKit: Build the examples." OFF)
option(ZK_BUILD_TESTS "ZenKit: Build the test suite." ON)
option(ZK_BUILD_SHARED "ZenKit: Build a shared library." OFF)
option(ZK_ENABLE_ASAN "ZenKit: Enable sanitizers in debug builds." ON)
option(ZK_ENABLE_DEPRECATION "ZenKit: Enable deprecation warnings." ON)
option(ZK_ENABLE_INSTALL "ZenKit: Enable CMake install target creation." ON)
option(ZK_ENABLE_MMAP "ZenKit: Build ZenKit with memory-mapping support." ON)
option(ZK_ENABLE_FUTURE "ZenKit: Enable breaking changes to be release in a future version" OFF)
add_subdirectory(vendor)
# find all header files; required for them to show up properly in VisualStudio
file(GLOB_RECURSE _ZK_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/include/**/*.hh")
list(APPEND _ZK_SOURCES
src/__legacy_buffer.cc
src/world/BspTree.cc
src/world/VobTree.cc
src/world/WayNet.cc
src/vobs/Camera.cc
src/vobs/Light.cc
src/vobs/Misc.cc
src/vobs/MovableObject.cc
src/vobs/Sound.cc
src/vobs/Trigger.cc
src/vobs/VirtualObject.cc
src/vobs/Zone.cc
src/addon/daedalus.cc
src/addon/texcvt.cc
src/archive/ArchiveAscii.cc
src/archive/ArchiveBinary.cc
src/archive/ArchiveBinsafe.cc
src/Archive.cc
src/Boxes.cc
src/CutsceneLibrary.cc
src/DaedalusScript.cc
src/Date.cc
src/DaedalusVm.cc
src/Error.cc
src/Font.cc
src/Logger.cc
src/Material.cc
src/Mesh.cc
src/Misc.cc
src/Model.cc
src/ModelAnimation.cc
src/ModelHierarchy.cc
src/ModelMesh.cc
src/ModelScript.cc
src/ModelScriptDsl.cc
src/MorphMesh.cc
src/MultiResolutionMesh.cc
src/Object.cc
src/SaveGame.cc
src/SoftSkinMesh.cc
src/Stream.cc
src/Texture.cc
src/Vfs.cc
src/World.cc
)
list(APPEND _ZK_TESTS
tests/TestArchive.cc
tests/TestCutsceneLibrary.cc
tests/TestDaedalusScript.cc
tests/TestFont.cc
tests/TestMaterial.cc
tests/TestModel.cc
tests/TestModelAnimation.cc
tests/TestModelHierarchy.cc
tests/TestModelMesh.cc
tests/TestModelScript.cc
tests/TestMorphMesh.cc
tests/TestMultiResolutionMesh.cc
tests/TestSaveGame.cc
tests/TestStream.cc
tests/TestTexture.cc
tests/TestVfs.cc
tests/TestVobsG1.cc
tests/TestVobsG2.cc
tests/TestWorld.cc
)
if (BUILD_SHARED_LIBS AND ZK_BUILD_SHARED)
add_library(zenkit SHARED)
set_target_properties(zenkit PROPERTIES CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN 1)
target_compile_definitions(zenkit PRIVATE ZKDYN=1)
else ()
add_library(zenkit STATIC)
endif ()
if (NOT ZK_ENABLE_DEPRECATION)
target_compile_definitions(zenkit PUBLIC ZKNO_REM=1)
endif ()
if (ZK_ENABLE_FUTURE)
target_compile_definitions(zenkit PUBLIC ZK_FUTURE=1)
endif ()
include(support/BuildSupport.cmake)
bs_select_cflags(${ZK_ENABLE_ASAN} _ZK_COMPILE_FLAGS _ZK_LINK_FLAGS)
bs_check_posix_mmap(_ZK_HAS_MMAP_POSIX)
bs_check_win32_mmap(_ZK_HAS_MMAP_WIN32)
if (ZK_ENABLE_MMAP AND (_ZK_HAS_MMAP_POSIX OR _ZK_HAS_MMAP_WIN32))
if (_ZK_HAS_MMAP_POSIX)
message(STATUS "ZenKit: Building with POSIX memory mapping support")
list(APPEND _ZK_SOURCES src/MmapPosix.cc)
target_compile_definitions(zenkit PUBLIC _ZK_WITH_MMAP=1)
elseif (_ZK_HAS_MMAP_WIN32)
message(STATUS "ZenKit: Building with Windows memory mapping support")
list(APPEND _ZK_SOURCES src/MmapWin32.cc)
target_compile_definitions(zenkit PUBLIC _ZK_WITH_MMAP=1)
endif ()
else ()
message(WARNING "ZenKit: Building WITHOUT memory mapping support")
endif ()
target_sources(zenkit PRIVATE ${_ZK_SOURCES} ${_ZK_HEADERS})
target_include_directories(zenkit PUBLIC include)
target_compile_definitions(zenkit PRIVATE _ZKEXPORT=1 ZKNO_REM=1)
target_compile_options(zenkit PRIVATE ${_ZK_COMPILE_FLAGS})
target_link_options(zenkit PUBLIC ${_ZK_LINK_FLAGS})
target_link_libraries(zenkit PUBLIC glm::glm_static squish)
set_target_properties(zenkit PROPERTIES DEBUG_POSTFIX "d" VERSION ${PROJECT_VERSION})
if (ZK_ENABLE_INSTALL)
install(TARGETS zenkit ARCHIVE LIBRARY RUNTIME)
install(DIRECTORY "include/phoenix" TYPE INCLUDE)
install(DIRECTORY "include/zenkit" TYPE INCLUDE)
if (NOT ZK_BUILD_SHARED)
# For static linking we'll need to provide the dependency static libraries
install(DIRECTORY "${glm_SOURCE_DIR}/glm" TYPE INCLUDE FILES_MATCHING PATTERN "*.hpp" PATTERN "*.inl" PATTERN "*.h")
foreach (lib glm::glm_static)
install(FILES "$<TARGET_LINKER_FILE:${lib}>" TYPE LIB)
endforeach ()
endif ()
endif ()
# when building tests, create a test executable and load it into CTest
if (ZK_BUILD_TESTS AND CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
enable_testing()
include(${doctest_SOURCE_DIR}/scripts/cmake/doctest.cmake)
add_executable(test-zenkit ${_ZK_TESTS})
target_link_libraries(test-zenkit PRIVATE zenkit doctest_with_main)
target_compile_options(test-zenkit PRIVATE ${_ZK_COMPILE_FLAGS})
target_link_options(test-zenkit PUBLIC ${_ZK_LINK_FLAGS})
doctest_discover_tests(test-zenkit EXTRA_ARGS -tse=CutsceneLibrary,DaedalusScript,World WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/tests)
endif ()
# when building examples, include the subdirectory
if (ZK_BUILD_EXAMPLES)
add_subdirectory(examples)
endif ()