|
1 |
| -# oh yes sir, the Linux support is gonna be here soon |
| 1 | +cmake_minimum_required(VERSION 3.10) |
2 | 2 |
|
3 |
| -# TODO: |
4 |
| -# WASNT TESTED YET |
5 |
| -# MORE CMAKE THINGIES (line 81-85) |
6 |
| -# CHECK IF IT WILL EVEN COMPILE |
| 3 | +# Project Name and Version |
| 4 | +project(SourceDEFUN VERSION 1.0.0) |
7 | 5 |
|
8 |
| -cmake_minimum_required(VERSION 3.18 FATAL_ERROR) |
9 |
| - |
10 |
| -set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE) |
11 |
| - |
12 |
| -if (APPLE) |
13 |
| - # Secton: UNTESTED |
14 |
| - # NOTE: You will need to pass this as a command line parameter for the Xcode generator -DCMAKE_OSX_ARCHITECTURES=i386 |
15 |
| - # Also note only Xcode 9.4.1 and earlier support i386 |
16 |
| - set(CMAKE_OSX_ARCHITECTURES i386) |
17 |
| - set(CMAKE_OSX_DEPLOYMENT_TARGET 10.9) |
18 |
| - set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf-with-dsym") |
19 |
| -endif() |
20 |
| - |
21 |
| -project(SourceDEFUN) |
22 |
| - |
23 |
| -# For some reason, checking if CMAKE_BUILD_TYPE is defined is unreliable |
24 |
| -# So simply check if it's empty instead |
25 |
| -if ("${CMAKE_BUILD_TYPE}" STREQUAL "") |
26 |
| - set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type" FORCE) |
27 |
| -endif() |
28 |
| - |
29 |
| -# Modern VS versions default to C++14 anyway, so make it consistent |
30 |
| -# But in the future we may want so support C++20 |
31 |
| -set(CMAKE_CXX_STANDARD 14) |
32 |
| -set(CMAKE_CXX_STANDARD_REQUIRED ON) |
33 |
| -set(CMAKE_CXX_VISIBILITY_PRESET hidden) |
34 |
| -set_property(GLOBAL PROPERTY USE_FOLDERS ON) |
35 |
| - |
36 |
| -# This is a way to emulate groups.vgc |
37 |
| -set(BUILD_GROUP "game" CACHE STRING "Build Group") |
38 |
| - |
39 |
| -# For the CMake GUIs that support a combobox list |
40 |
| -set_property(CACHE BUILD_GROUP PROPERTY STRINGS |
41 |
| - "everything" |
42 |
| - "game" |
43 |
| - "shaders" |
44 |
| -) |
45 |
| - |
46 |
| -# Which game are we building? |
47 |
| -set(BUILD_GAME "hl2" CACHE STRING "Build Game") |
48 |
| - |
49 |
| -set_property( |
50 |
| - CACHE BUILD_GAME PROPERTY STRINGS |
51 |
| - "defunmod" |
52 |
| -) |
53 |
| - |
54 |
| -set(SRCDIR "${CMAKE_CURRENT_LIST_DIR}") |
55 |
| -set(GAMEDIR "${CMAKE_CURRENT_LIST_DIR}/game") |
56 |
| -# It's a commented code don't highlight ok? | set(THIRDPARTYDIR "${SRCDIR}/thirdparty") |
57 |
| - |
58 |
| -# Compile options that are populated and set for each target depending on their type |
59 |
| -set(ADDITIONAL_COMPILE_OPTIONS_EXE) |
60 |
| -set(ADDITIONAL_COMPILE_OPTIONS_DLL) |
61 |
| -set(ADDITIONAL_COMPILE_OPTIONS_LIB) |
62 |
| - |
63 |
| -# Libraries that are linked to for each target depending on their type |
64 |
| -set(ADDITIONAL_LINK_LIBRARIES_EXE) |
65 |
| -set(ADDITIONAL_LINK_LIBRARIES_DLL) |
66 |
| - |
67 |
| -# Linker options that are populated and set for each target depending on their type |
68 |
| -set(ADDITIONAL_LINK_OPTIONS_EXE) |
69 |
| -set(ADDITIONAL_LINK_OPTIONS_DLL) |
70 |
| -set(ADDITIONAL_LINK_OPTIONS_LIB) |
71 |
| - |
72 |
| -# Sources that are added to each target depending on their type |
73 |
| -set(ADDITIONAL_SOURCES_EXE) |
74 |
| -set(ADDITIONAL_SOURCES_DLL) |
75 |
| -set(ADDITIONAL_SOURCES_LIB) |
76 |
| - |
77 |
| -# Compile definitions that are added to each target depending on their type |
78 |
| -set(ADDITIONAL_COMPILE_DEFINITIONS_EXE) |
79 |
| -set(ADDITIONAL_COMPILE_DEFINITIONS_DLL) |
80 |
| -set(ADDITIONAL_COMPILE_DEFINITIONS_LIB) |
81 |
| - |
82 |
| -include("_cmake_scripts/pch_skip.cmake") |
83 |
| -include("_cmake_scripts/platform_dirs.cmake") |
84 |
| -include("_cmake_scripts/base.cmake") |
85 |
| -include("_cmake_scripts/video_base.cmake") |
86 |
| -include("_cmake_scripts/postbuild.cmake") |
87 |
| - |
88 |
| -set(LIBPUBLIC "${SRCDIR}/lib/public${PLATSUBDIR}") |
89 |
| -set(LIBCOMMON "${SRCDIR}/lib/common${PLATSUBDIR}") |
90 |
| - |
91 |
| -link_directories( |
92 |
| - ${LIBPUBLIC} |
93 |
| - ${LIBCOMMON} |
94 |
| -) |
95 |
| - |
96 |
| -include_directories( |
97 |
| - "${SRCDIR}/common" |
98 |
| - "${SRCDIR}/public" |
99 |
| - "${SRCDIR}/public/tier0" |
100 |
| - "${SRCDIR}/public/tier1" |
101 |
| - "${SRCDIR}/public/tier2" # Not sure if necessary |
102 |
| - "${SRCDIR}/public/tier3" # Ditto |
103 |
| -) |
104 |
| - |
105 |
| -add_compile_definitions($<$<CONFIG:Debug>:DEBUG> $<$<CONFIG:Debug>:_DEBUG>) |
106 |
| -add_compile_definitions($<$<CONFIG:Release>:NDEBUG>) |
107 |
| - |
108 |
| -if (${IS_WINDOWS}) |
109 |
| - include("_cmake_scripts/windows_base.cmake") |
110 |
| -elseif (${IS_LINUX} OR ${IS_OSX}) |
111 |
| - include("_cmake_scripts/posix_base.cmake") |
112 |
| -endif() |
113 |
| - |
114 |
| -include("_cmake_scripts/groups.cmake") |
115 |
| - |
116 |
| -# Store all targets in a variable name ( See: https://stackoverflow.com/questions/37434946/how-do-i-iterate-over-all-cmake-targets-programmatically/62311397#62311397 ) |
117 |
| -function(get_all_targets var) |
118 |
| - set(targets) |
119 |
| - get_all_targets_recursive(targets ${CMAKE_CURRENT_SOURCE_DIR}) |
120 |
| - set(${var} ${targets} PARENT_SCOPE) |
121 |
| -endfunction() |
122 |
| - |
123 |
| -macro(get_all_targets_recursive targets dir) |
124 |
| - get_property(subdirectories DIRECTORY ${dir} PROPERTY SUBDIRECTORIES) |
125 |
| - foreach(subdir ${subdirectories}) |
126 |
| - get_all_targets_recursive(${targets} ${subdir}) |
127 |
| - endforeach() |
128 |
| - |
129 |
| - get_property(current_targets DIRECTORY ${dir} PROPERTY BUILDSYSTEM_TARGETS) |
130 |
| - list(APPEND ${targets} ${current_targets}) |
131 |
| -endmacro() |
132 |
| - |
133 |
| -get_all_targets(ALL_TARGETS) |
134 |
| - |
135 |
| -# Set of helper functions to add defintions/options/libs for each target in a filtered way |
136 |
| -function(add_compile_definitions_filtered target definitions) |
137 |
| - foreach(additional_definition IN LISTS ${definitions}) |
138 |
| - set(SHOULD_EXCLUDE 0) |
139 |
| - # Exclude the compile definition if target defines an exclude list |
140 |
| - foreach(exclude IN LISTS "${target}_exclude_compile_definitions") |
141 |
| - if (${additional_definition} STREQUAL ${exclude}) |
142 |
| - set(SHOULD_EXCLUDE 1) |
143 |
| - break() |
144 |
| - endif() |
145 |
| - endforeach() |
146 |
| - if (NOT ${SHOULD_EXCLUDE}) |
147 |
| - target_compile_definitions(${target} PRIVATE ${additional_definition}) |
148 |
| - endif() |
149 |
| - endforeach() |
150 |
| -endfunction() |
151 |
| - |
152 |
| - |
153 |
| -function(add_compile_options_filtered target options) |
154 |
| - foreach(additional_option IN LISTS ${options}) |
155 |
| - set(SHOULD_EXCLUDE 0) |
156 |
| - # Exclude the compile options if target defines an exclude list |
157 |
| - foreach(exclude IN LISTS "${target}_exclude_compile_options") |
158 |
| - if (${additional_option} STREQUAL ${exclude}) |
159 |
| - set(SHOULD_EXCLUDE 1) |
160 |
| - break() |
161 |
| - endif() |
162 |
| - endforeach() |
163 |
| - if (NOT ${SHOULD_EXCLUDE}) |
164 |
| - target_compile_options(${target} PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:${additional_option}>") |
165 |
| - endif() |
166 |
| - endforeach() |
167 |
| -endfunction() |
168 |
| - |
169 |
| -function(add_sources_filtered target sources) |
170 |
| - foreach(additional_source IN LISTS ${sources}) |
171 |
| - set(SHOULD_EXCLUDE 0) |
172 |
| - # Exclude the source if target defines an exclude list |
173 |
| - foreach(exclude IN LISTS "${target}_exclude_source") |
174 |
| - if (${additional_source} STREQUAL ${exclude}) |
175 |
| - set(SHOULD_EXCLUDE 1) |
176 |
| - break() |
177 |
| - endif() |
178 |
| - endforeach() |
179 |
| - if (NOT ${SHOULD_EXCLUDE}) |
180 |
| - target_sources(${target} PRIVATE ${additional_source}) |
181 |
| - endif() |
182 |
| - endforeach() |
183 |
| -endfunction() |
184 |
| - |
185 |
| -function(add_libraries_filtered target libraries) |
186 |
| - foreach(additional_lib IN LISTS ${libraries}) |
187 |
| - set(SHOULD_EXCLUDE 0) |
188 |
| - # Exclude the lib if target defines an exclude list |
189 |
| - foreach(exclude IN LISTS "${target}_exclude_lib") |
190 |
| - if (${additional_lib} STREQUAL ${exclude}) |
191 |
| - set(SHOULD_EXCLUDE 1) |
192 |
| - break() |
193 |
| - endif() |
194 |
| - endforeach() |
195 |
| - if (NOT ${SHOULD_EXCLUDE}) |
196 |
| - get_target_property(libraries ${target} LINK_LIBRARIES) |
197 |
| - # Don't bother adding it if the target already links it manually |
198 |
| - foreach(lib IN LISTS libraries) |
199 |
| - if (${additional_lib} STREQUAL ${lib}) |
200 |
| - set(SHOULD_EXCLUDE 1) |
201 |
| - break() |
202 |
| - endif() |
203 |
| - endforeach() |
204 |
| - endif() |
205 |
| - if (NOT ${SHOULD_EXCLUDE}) |
206 |
| - target_link_libraries(${target} PRIVATE ${additional_lib}) |
207 |
| - endif() |
208 |
| - endforeach() |
209 |
| -endfunction() |
210 |
| - |
211 |
| -# Iterates over all the targets and add necessary definitions/options/libs |
212 |
| -# This is an incredible hack, but it allows for targets to specify exclude lists |
213 |
| -# This allows us to emulate -$File and such from VPC |
214 |
| -foreach(target ${ALL_TARGETS}) |
215 |
| - # Define an empty exclude list if one isn't defined |
216 |
| - if (NOT DEFINED "${target}_exclude_compile_options") |
217 |
| - set("${target}_exclude_compile_options") |
218 |
| - endif() |
219 |
| - |
220 |
| - # Define an empty exclude list if one isn't defined |
221 |
| - if (NOT DEFINED "${target}_exclude_lib") |
222 |
| - set("${target}_exclude_lib") |
223 |
| - endif() |
224 |
| - |
225 |
| - # Define an empty exclude list if one isn't defined |
226 |
| - if (NOT DEFINED "${target}_exclude_source") |
227 |
| - set("${target}_exclude_source") |
228 |
| - endif() |
229 |
| - |
230 |
| - get_target_property(target_type ${target} TYPE) |
231 |
| - if (${target_type} STREQUAL "EXECUTABLE") |
232 |
| - add_compile_options_filtered(${target} ADDITIONAL_COMPILE_OPTIONS_EXE) |
233 |
| - add_libraries_filtered(${target} ADDITIONAL_LINK_LIBRARIES_EXE) |
234 |
| - add_sources_filtered(${target} ADDITIONAL_SOURCES_EXE) |
235 |
| - target_link_options(${target} PRIVATE ${ADDITIONAL_LINK_OPTIONS_EXE}) |
236 |
| - target_compile_definitions(${target} PRIVATE MEMOVERRIDE_MODULE=$<TARGET_NAME_IF_EXISTS:${target}>) |
237 |
| - add_compile_definitions_filtered(${target} ADDITIONAL_COMPILE_DEFINITIONS_EXE) |
238 |
| - |
239 |
| - # Only applies to Linux and OSX |
240 |
| - target_strip_symbols(${target}) |
241 |
| - elseif((${target_type} STREQUAL "SHARED_LIBRARY") OR (${target_type} STREQUAL "MODULE_LIBRARY")) |
242 |
| - add_compile_options_filtered(${target} ADDITIONAL_COMPILE_OPTIONS_DLL) |
243 |
| - add_libraries_filtered(${target} ADDITIONAL_LINK_LIBRARIES_DLL) |
244 |
| - add_sources_filtered(${target} ADDITIONAL_SOURCES_DLL) |
245 |
| - target_link_options(${target} PRIVATE ${ADDITIONAL_LINK_OPTIONS_DLL}) |
246 |
| - target_compile_definitions(${target} PRIVATE MEMOVERRIDE_MODULE=$<TARGET_NAME_IF_EXISTS:${target}> DLLNAME=$<TARGET_NAME_IF_EXISTS:${target}>) |
247 |
| - add_compile_definitions_filtered(${target} ADDITIONAL_COMPILE_DEFINITIONS_DLL) |
248 |
| - |
249 |
| - # Only applies to Linux and OSX |
250 |
| - target_strip_symbols(${target}) |
251 |
| - elseif(${target_type} STREQUAL "STATIC_LIBRARY") |
252 |
| - add_compile_options_filtered(${target} ADDITIONAL_COMPILE_OPTIONS_LIB) |
253 |
| - add_sources_filtered(${target} ADDITIONAL_SOURCES_LIB) |
254 |
| - target_link_options(${target} PRIVATE ${ADDITIONAL_LINK_OPTIONS_LIB}) |
255 |
| - target_compile_definitions(${target} PRIVATE LIBNAME=$<TARGET_NAME_IF_EXISTS:${target}>) |
256 |
| - add_compile_definitions_filtered(${target} ADDITIONAL_COMPILE_DEFINITIONS_LIB) |
257 |
| - endif() |
258 |
| - |
259 |
| -endforeach() |
| 6 | +# Add subdirectories as projects |
| 7 | +add_subdirectory(game/client) |
| 8 | +add_subdirectory(game/server) |
| 9 | +add_subdirectory(materialsystem/swarmshaders) |
| 10 | +add_subdirectory(materialsystem/shaderlib) |
0 commit comments