Line
Link Here
|
0 |
-- CMakeLists.txt |
0 |
++ CMakeLists.txt |
Lines 10-18
Link Here
|
10 |
endif() |
10 |
endif() |
11 |
|
11 |
|
12 |
include( CMakeDependentOption ) |
12 |
include( CMakeDependentOption ) |
|
|
13 |
include(GNUInstallDirs) |
13 |
|
14 |
|
14 |
set( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" ) |
15 |
set( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" ) |
15 |
set( CMAKE_C_FLAGS "-msse2 -pipe" CACHE STRING "" ) |
|
|
16 |
set( CMAKE_C_FLAGS_DEBUG "-g" CACHE STRING "" ) |
16 |
set( CMAKE_C_FLAGS_DEBUG "-g" CACHE STRING "" ) |
17 |
set( CMAKE_C_FLAGS_MINSIZEREL "-DNDEBUG -Os" CACHE STRING "" ) |
17 |
set( CMAKE_C_FLAGS_MINSIZEREL "-DNDEBUG -Os" CACHE STRING "" ) |
18 |
set( CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O3 -ffast-math -fomit-frame-pointer -fno-strict-aliasing" CACHE STRING "" ) |
18 |
set( CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O3 -ffast-math -fomit-frame-pointer -fno-strict-aliasing" CACHE STRING "" ) |
Lines 56-64
Link Here
|
56 |
option( USE_INTERNAL_CRYPTO "Use internal crypto (nettle)" 0 ) |
56 |
option( USE_INTERNAL_CRYPTO "Use internal crypto (nettle)" 0 ) |
57 |
option( NO_UNTRUSTED_PLUGINS "Don't load native plugins from the user dir" 1 ) |
57 |
option( NO_UNTRUSTED_PLUGINS "Don't load native plugins from the user dir" 1 ) |
58 |
|
58 |
|
59 |
option( ENABLE_W_ALL "Use -Wall" 0 ) |
|
|
60 |
option( ENABLE_WARNINGS "Enable various compiler warning options" 1 ) |
61 |
option( ENABLE_HARDENING "Enable various hardening options" 1 ) |
62 |
|
59 |
|
63 |
cmake_dependent_option( BUILD_GAME_GPP "Build Tremulous GPP game logic" 1 "GAME_LIB OR GAME_QVM" 0 ) |
60 |
cmake_dependent_option( BUILD_GAME_GPP "Build Tremulous GPP game logic" 1 "GAME_LIB OR GAME_QVM" 0 ) |
64 |
cmake_dependent_option( QVM_DEBUG "Enable (some) QVM debugging" 1 GAME_QVM 0 ) |
61 |
cmake_dependent_option( QVM_DEBUG "Enable (some) QVM debugging" 1 GAME_QVM 0 ) |
Lines 172-305
Link Here
|
172 |
|
169 |
|
173 |
include_directories( "${CMAKE_BINARY_DIR}/CMakeFiles" ) |
170 |
include_directories( "${CMAKE_BINARY_DIR}/CMakeFiles" ) |
174 |
|
171 |
|
175 |
################# |
|
|
176 |
# Compile flags # |
177 |
################# |
178 |
|
179 |
macro( try_compiler_flag_internal PROP FLAG CC SUFFIX LABEL ) |
180 |
set( SAVED_FLAGS "${CMAKE_${CC}_FLAGS}" ) |
181 |
set( CMAKE_${CC}_FLAGS "${CMAKE_${CC}_FLAGS} ${FLAG}" ) |
182 |
# test it on an executable |
183 |
if( NOT ${PROP}_${CC}_CACHED ) |
184 |
try_compile( ${PROP}_${CC} ${MOUNT_DIR}/tests ${MOUNT_DIR}/tests/test.${SUFFIX} |
185 |
CMAKE_FLAGS "-DCMAKE_${CC}_FLAGS=${CMAKE_${CC}_FLAGS}" ) |
186 |
endif() |
187 |
if( ${PROP}_${CC} ) |
188 |
if( NOT ${PROP}_${CC}_CACHED ) |
189 |
message( STATUS "Using ${LABEL} flag ${FLAG}" ) |
190 |
endif() |
191 |
else() |
192 |
if( NOT ${PROP}_${CC}_CACHED ) |
193 |
message( STATUS "${LABEL} flag ${FLAG} is not available" ) |
194 |
endif() |
195 |
set( CMAKE_${CC}_FLAGS "${SAVED_FLAGS}" ) |
196 |
endif() |
197 |
set( ${PROP}_${CC}_CACHED TRUE CACHE INTERNAL "Set if ${LABEL} option ${FLAG} has been checked for." ) |
198 |
endmacro() |
199 |
|
200 |
macro( try_c_flag PROP FLAG ) |
201 |
try_compiler_flag_internal( ${PROP} ${FLAG} C c C ) |
202 |
endmacro() |
203 |
|
204 |
macro( try_cxx_flag PROP FLAG ) |
205 |
try_compiler_flag_internal( ${PROP} ${FLAG} CXX cxx C++) |
206 |
endmacro() |
207 |
|
208 |
macro( try_llvm_flag PROP FLAG ) |
209 |
try_compiler_flag_internal( ${PROP} ${FLAG} LLVM cc C/LLVM) |
210 |
endmacro() |
211 |
|
212 |
macro( try_c_llvm_flag PROP FLAG ) |
213 |
try_c_flag( ${PROP} ${FLAG} ) |
214 |
if( GAME_LIB_LLVM ) |
215 |
try_llvm_flag( ${PROP} ${FLAG} ) |
216 |
endif() |
217 |
endmacro() |
218 |
|
219 |
macro( try_c_cxx_flag PROP FLAG ) |
220 |
try_c_flag( ${PROP} ${FLAG} ) |
221 |
try_cxx_flag( ${PROP} ${FLAG} ) |
222 |
endmacro() |
223 |
|
224 |
macro( try_c_cxx_llvm_flag PROP FLAG ) |
225 |
try_c_flag( ${PROP} ${FLAG} ) |
226 |
try_cxx_flag( ${PROP} ${FLAG} ) |
227 |
if( GAME_LIB_LLVM ) |
228 |
try_llvm_flag( ${PROP} ${FLAG} ) |
229 |
endif() |
230 |
endmacro() |
231 |
|
232 |
# Various warnings |
233 |
if( ENABLE_W_ALL ) |
234 |
try_c_cxx_llvm_flag( HAVE_W_ALL -Wall ) |
235 |
endif() |
236 |
if( ENABLE_WARNINGS ) |
237 |
try_c_cxx_llvm_flag( HAVE_W_FORMAT2 -Wformat=2 ) |
238 |
if( NOT HAVE_W_FORMAT2_C ) |
239 |
try_c_cxx_llvm_flag( HAVE_W_FORMAT -Wformat ) |
240 |
endif() |
241 |
try_c_llvm_flag ( HAVE_W_0LEN_FMT -Wno-format-zero-length ) |
242 |
try_c_cxx_llvm_flag( HAVE_W_FORMAT_SECURITY -Wformat-security ) |
243 |
try_c_cxx_llvm_flag( HAVE_W_STRICT_ALIAS_2 -Wstrict-aliasing=2 ) |
244 |
try_c_cxx_llvm_flag( HAVE_W_MISSING_FMT_ATTR -Wmissing-format-attribute ) |
245 |
try_c_cxx_llvm_flag( HAVE_W_MISSING_NORETURN -Wmissing-noreturn ) |
246 |
try_c_llvm_flag ( HAVE_W_IMPLICIT_FN -Wimplicit-function-declaration ) |
247 |
if( HAVE_W_IMPLICIT_FN_C ) |
248 |
try_c_cxx_llvm_flag( HAVE_W_ERR_IMPLICIT_FN -Werror=implicit-function-declaration ) |
249 |
endif() |
250 |
try_c_cxx_llvm_flag( HAVE_W_FMT_SECURITY -Wformat-security ) |
251 |
if( HAVE_W_FMT_SECURITY_C ) |
252 |
try_c_cxx_llvm_flag( HAVE_W_ERR_FMT_SECURITY -Werror=format-security ) |
253 |
endif() |
254 |
endif() |
255 |
|
256 |
# Hardening |
257 |
if( ENABLE_HARDENING ) |
258 |
try_c_cxx_flag( HAVE_F_STACK_PROTECTOR -fstack-protector ) |
259 |
endif() |
260 |
|
261 |
############## |
262 |
# Link flags # |
263 |
############## |
264 |
|
265 |
macro( try_linker_flag PROP FLAG ) |
266 |
set( SAVED_FLAGS "${CMAKE_EXE_LINKER_FLAGS}" ) |
267 |
set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${FLAG}" ) |
268 |
# test it on an executable |
269 |
if( NOT ${PROP}_CACHED ) |
270 |
try_compile( ${PROP} ${MOUNT_DIR}/tests ${MOUNT_DIR}/tests/test.c |
271 |
CMAKE_FLAGS -DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS} ) |
272 |
endif() |
273 |
if( ${PROP} ) |
274 |
if( NOT ${PROP}_CACHED ) |
275 |
message( STATUS "Using linker flag ${FLAG}" ) |
276 |
endif() |
277 |
# assume that it works for shared & static libs too |
278 |
set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${FLAG}" ) |
279 |
set( CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${FLAG}" ) |
280 |
else() |
281 |
if( NOT ${PROP}_CACHED ) |
282 |
message( STATUS "Linker flag ${FLAG} is not available" ) |
283 |
endif() |
284 |
set( CMAKE_EXE_LINKER_FLAGS "${SAVED_FLAGS}" ) |
285 |
endif() |
286 |
set( ${PROP}_CACHED TRUE CACHE INTERNAL "Set if linker option ${FLAG} has been checked for." ) |
287 |
endmacro() |
288 |
|
289 |
# Can we get rid of unneeded external libraries? |
290 |
try_linker_flag( HAVE_AS_NEEDED -Wl,--as-needed ) |
291 |
|
292 |
# If we can, fail if there are unresolved symbols |
293 |
try_linker_flag( HAVE_Z_DEFS -Wl,-z,defs ) |
294 |
|
295 |
if( ENABLE_HARDENING ) |
296 |
if( ENABLE_FSTACKPROT ) |
297 |
try_linker_flag( HAVE_FSTACKPROT "-fstack-protector --param=ssp-buffer-size=4" ) |
298 |
endif() |
299 |
if( ENABLE_RELRO ) |
300 |
try_linker_flag( HAVE_Z_RELRO_Z_NOW -Wl,-z,relro,-z,now ) |
301 |
endif() |
302 |
endif() |
303 |
|
172 |
|
304 |
###################### |
173 |
###################### |
305 |
# Define Build Files # |
174 |
# Define Build Files # |
Lines 1266-1276
Link Here
|
1266 |
include_directories( ${MOUNT_DIR}/libs/cpuinfo ${NEWTON_INCLUDES} ) |
1135 |
include_directories( ${MOUNT_DIR}/libs/cpuinfo ${NEWTON_INCLUDES} ) |
1267 |
target_link_libraries( client ${OS_LIBRARIES} ${NEWTON_LIBRARY} ) |
1136 |
target_link_libraries( client ${OS_LIBRARIES} ${NEWTON_LIBRARY} ) |
1268 |
set_property( TARGET client APPEND PROPERTY COMPILE_DEFINITIONS USE_XREAL_RENDERER COMPAT_ET USE_REFENTITY_ANIMATIONSYSTEM USE_CRYPTO ) |
1137 |
set_property( TARGET client APPEND PROPERTY COMPILE_DEFINITIONS USE_XREAL_RENDERER COMPAT_ET USE_REFENTITY_ANIMATIONSYSTEM USE_CRYPTO ) |
1269 |
set_target_properties( client PROPERTIES OUTPUT_NAME "daemon.${BUILD_ARCH}" PREFIX "" LINKER_LANGUAGE CXX ) |
1138 |
set_target_properties( client PROPERTIES OUTPUT_NAME "daemon" PREFIX "" LINKER_LANGUAGE CXX ) |
1270 |
install( TARGETS client |
1139 |
install( TARGETS client |
1271 |
RUNTIME DESTINATION bin |
1140 |
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} |
1272 |
LIBRARY DESTINATION lib |
1141 |
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
1273 |
ARCHIVE DESTINATION lib |
1142 |
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
1274 |
) |
1143 |
) |
1275 |
|
1144 |
|
1276 |
# Mac OS X specific settings |
1145 |
# Mac OS X specific settings |
Lines 1416-1426
Link Here
|
1416 |
include_directories( ${MOUNT_DIR}/libs/cpuinfo ${NEWTON_INCLUDES} ) |
1285 |
include_directories( ${MOUNT_DIR}/libs/cpuinfo ${NEWTON_INCLUDES} ) |
1417 |
target_link_libraries( server ${OS_LIBRARIES} ${NEWTON_LIBRARY} ) |
1286 |
target_link_libraries( server ${OS_LIBRARIES} ${NEWTON_LIBRARY} ) |
1418 |
set_property( TARGET server APPEND PROPERTY COMPILE_DEFINITIONS DEDICATED COMPAT_ET USE_CRYPTO ) |
1287 |
set_property( TARGET server APPEND PROPERTY COMPILE_DEFINITIONS DEDICATED COMPAT_ET USE_CRYPTO ) |
1419 |
set_target_properties( server PROPERTIES OUTPUT_NAME "daemonded.${BUILD_ARCH}" PREFIX "" LINKER_LANGUAGE CXX ) |
1288 |
set_target_properties( server PROPERTIES OUTPUT_NAME "daemonded" PREFIX "" LINKER_LANGUAGE CXX ) |
1420 |
install( TARGETS server |
1289 |
install( TARGETS server |
1421 |
RUNTIME DESTINATION bin |
1290 |
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} |
1422 |
LIBRARY DESTINATION lib |
1291 |
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
1423 |
ARCHIVE DESTINATION lib |
1292 |
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
1424 |
) |
1293 |
) |
1425 |
|
1294 |
|
1426 |
# Mac OS X has some trouble with PIC code under X86/32. |
1295 |
# Mac OS X has some trouble with PIC code under X86/32. |
Lines 1487-1497
Link Here
|
1487 |
include_directories( ${LIB_DIR}/picomodel ${MOUNT_DIR}/tools/common ) |
1356 |
include_directories( ${LIB_DIR}/picomodel ${MOUNT_DIR}/tools/common ) |
1488 |
target_link_libraries( daemonMap ${OS_LIBRARIES} ) |
1357 |
target_link_libraries( daemonMap ${OS_LIBRARIES} ) |
1489 |
set_property( TARGET daemonMap APPEND PROPERTY COMPILE_DEFINITIONS USE_OPENGL ) |
1358 |
set_property( TARGET daemonMap APPEND PROPERTY COMPILE_DEFINITIONS USE_OPENGL ) |
1490 |
set_target_properties( daemonMap PROPERTIES OUTPUT_NAME "daemonmap.${BUILD_ARCH}" PREFIX "" ) |
1359 |
set_target_properties( daemonMap PROPERTIES OUTPUT_NAME "daemonmap" PREFIX "" ) |
1491 |
install( TARGETS daemonMap |
1360 |
install( TARGETS daemonMap |
1492 |
RUNTIME DESTINATION bin |
1361 |
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} |
1493 |
LIBRARY DESTINATION lib |
1362 |
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
1494 |
ARCHIVE DESTINATION lib |
1363 |
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
1495 |
) |
1364 |
) |
1496 |
# This section finds and provides REQUIRED dependencies to DaemonMap target |
1365 |
# This section finds and provides REQUIRED dependencies to DaemonMap target |
1497 |
find_package( OpenGL REQUIRED ) |
1366 |
find_package( OpenGL REQUIRED ) |