1 cmake_minimum_required(VERSION 3.0)
2 if(COMMAND cmake_policy)
3 cmake_policy(SET CMP0003 NEW)
4 cmake_policy(SET CMP0026 NEW)
5 endif(COMMAND cmake_policy)
9 include(CheckIncludeFile)
12 option(WITH_SDL2 "Use SDL2 library" ON)
13 option(WITH_OPENGL "Use OpenGL library" ON)
14 option(WITH_MIMALLOC "Use mi-malloc memory allocator" ON)
15 option(WITH_MOJOAL "Enable MojoAL OpenAL impletentation over SDL Mixer" OFF)
16 option(WITH_SYS_OPUS "Enable Opus support via system libopus and libopusfile (if off, internal libraries will be used)" OFF)
17 option(WITH_SYS_VORBIS "Enable Vorbis support via libvorbis (if off, stb_vorbis will be used)" OFF)
18 option(WITH_LIBMAD "Enable MP3 support via libmad (if off, dr_mp3 will be used)" OFF)
19 option(WITH_SYS_FLAC "Enable FLAC support via libflac (if off, dr_flac will be used)" OFF)
20 option(WITH_FLUID "Enable FluidSynth support" ON)
21 option(WITH_LIBJIT "Enable LibJIT support in VavoomC compiler (don't use!)" OFF)
22 option(WITH_XRANDR "Enable XRandR support for DPI detection (don't use!)" OFF)
23 option(WITH_WNT64 "Enable 64-bit build" OFF)
25 option(WITH_SYS_FLUID "Use system FluidSynth library" OFF)
27 option(WITH_SYS_FLUID "Use system FluidSynth library" ON)
31 option(WITH_GLES "Use hacks for GL4ES (experimental)" OFF)
32 option(WITH_GL4ES "Use GL4ES directly (experimental)" OFF)
37 if(GL4ES_LIBRARY_DIR STREQUAL "")
38 message(FATAL_ERROR "GL4ES_LIBRARY_DIR not setted")
40 if(GL4ES_INCLUDE_DIR STREQUAL "")
41 message(FATAL_ERROR "GL4ES_INCLUDE_DIR not setted")
46 option(WITH_STB_JPEG "Use stb_image to load jpegs" ON)
47 option(WITH_SYS_LIBJPG "Use system libjpg (if stb_image is off)" ON)
49 option(WITH_OLD_CPU "Use pIV CPU instruction set" OFF)
51 #option(WITH_RPATH "Use -rpath" OFF)
52 set(RPATH_VALUE "" CACHE STRING "-rpath linker option value")
55 option(WITH_SSE3 "Use SSE3 instruction set (may not compile)" OFF)
56 option(WITH_SSE4 "Use SSE4 instruction set (may not compile)" OFF)
57 option(WITH_SSE41 "Use SSE4.1 instruction set (may not compile)" OFF)
58 option(WITH_SSE42 "Use SSE4.2 instruction set (may not compile)" OFF)
59 option(NO_SSE "Disable all SSE instructions" OFF)
60 option(INSANE_AVX "Use AVX2 instruction set (don't do this, it won't give you any noticeable speedup and may be broken)" OFF)
62 # do not tempt poor things
63 if("$ENV{USER}" STREQUAL "ketmar")
64 option(WITH_GCC_ANAL "Turn on gcc10 static analyzer" OFF)
65 option(WITH_GCC_IDIOCITY "Turn on gcc idiotic pseudo-warnings (don't care, won't fix)" OFF)
67 set(WITH_GCC_ANAL OFF)
68 set(WITH_GCC_IDIOCITY OFF)
71 option(WITH_GLAD "Use supplied GLAD for GL bindings" OFF)
72 option(NO_PTHREAD "Disable pthreads, use C11 threads instead" OFF)
73 option(NO_MEMRCHR "Disable usage of memrchr()" OFF)
74 option(NO_RAWTTY "Disable raw TTY control" OFF)
76 option(WITH_STRTODEX "Use internal strtod implementation to parse floats" ON)
78 # do not tempt poor things
79 if("$ENV{USER}" STREQUAL "ketmar")
80 option(DEBUG_FPU_CHECKS "Use FPU and turn on some checks (GNU/Linux only)" OFF)
81 option(UNSTABLE_OPTIMISATIONS "Use -O3 (WARNING! DON'T DO THAT! NEVER!)" OFF)
83 set(DEBUG_FPU_CHECKS OFF)
84 set(UNSTABLE_OPTIMISATIONS OFF)
87 if(CMAKE_CROSSCOMPILING AND WIN32)
88 option(SDL2_OVERRIDE "Some specific changes for custom-built SDL2 (do not turn on if you don't know what it is)" ON)
89 else(CMAKE_CROSSCOMPILING AND WIN32)
90 option(SDL2_OVERRIDE "Some specific changes for custom-built SDL2 (do not turn on if you don't know what it is)" OFF)
91 endif(CMAKE_CROSSCOMPILING AND WIN32)
93 if(CMAKE_CROSSCOMPILING AND WIN32)
95 option(WITH_WINE "Use wine to run built executables" ON)
96 option(WITH_STATIC_OPENAL "Use special flags to link with static OpenAL" ON)
99 endif(CMAKE_CROSSCOMPILING AND WIN32)
102 option(WITH_NXLINK "Redirect standard output to NXLink" OFF)
103 set(NO_SSE ON) # set it right away for proper logging and cflags
104 set(WITH_MIMALLOC OFF)
107 option(FOSSIL_REPO_PATH "Local path to k8vavoom Fossil repository (leave empty if unsure)" OFF)
112 set(WITH_MIMALLOC OFF)
115 # perform some platform and compiler checks
116 set(VV_STACK_REALIGN OFF)
117 if(CMAKE_CROSSCOMPILING AND WIN32)
118 # cross-compiling to shitdoze
119 message(STATUS "Cross-compiling to shitdoze...")
120 elseif(CMAKE_CROSSCOMPILING)
121 # cross-compiling to something else, let's play safe
122 message(STATUS "Turning off SSE and mi-malloc")
124 set(WITH_MIMALLOC OFF)
125 elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(i[0-9]86|x86|X86|amd64|AMD64|x86_64)")
127 #if(CMAKE_SIZEOF_VOID_P EQUAL 8)
128 # set(OPUS_CPU_X64 1)
130 # set(OPUS_CPU_X86 1)
132 set(VV_STACK_REALIGN ON)
133 #elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(arm|aarch64)")
134 # set(OPUS_CPU_ARM 1)
136 # compiling to something else, let's play safe
137 add_definitions(-DVV_NOT_X86)
138 message(STATUS "Turning off SSE and mi-malloc")
140 set(WITH_MIMALLOC OFF)
143 set( RES_FLAGS -Fpe-i386 )
146 message(STATUS "*** 64-bit builds are UNSUPPORTED ***")
147 add_definitions(-DSTK_TIMET_FIX)
148 set( RES_FLAGS -Fpe-x86-64 )
151 set(K8_UNFUCK_AS_GCC ON)
152 set(K8_UNFUCK_AS_SHITLANG OFF)
153 if(NOT CMAKE_COMPILER_IS_GNUCC)
154 if (APPLE OR CMAKE_HOST_APPLE OR XCODE_VERSION)
155 message(FATAL_ERROR "Apple platform is not supported.")
157 endif(APPLE OR CMAKE_HOST_APPLE OR XCODE_VERSION)
159 if (MSVC OR MSVC80 OR MSVC_IDE)
160 message(FATAL_ERROR "m$ compilers aren't supported. GTFO.")
162 endif(MSVC OR MSVC80 OR MSVC_IDE)
164 message(WARNING "Only GNU C/C++ compilers are supported to build k8vavoom and tools!")
165 message(WARNING "Your compiler is not GNU, please, don't report bugs.")
166 set(K8_UNFUCK_AS_GCC OFF)
168 if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
169 message(WARNING "And, by the way. clang sux.")
170 set(K8_UNFUCK_AS_SHITLANG ON)
172 endif(NOT CMAKE_COMPILER_IS_GNUCC)
174 option(ENABLE_CLIENT "Build client executable" ON)
175 option(ENABLE_SERVER "Build dedicated server executable (don't do that!)" OFF)
176 option(ENABLE_MASTER "Build master server (no reason to build it)" OFF)
177 option(ENABLE_QUERY_DEMO "Build query demo (can be used to send rcon commands)" OFF)
178 option(ENABLE_VCCRUN "Build vccrun executable" OFF)
179 option(ENABLE_MD2FIXER "Build fixmd2 executable (you don't need it)" OFF)
181 option(ENABLE_VCCRUN_ONLY "Build ONLY vccrun" OFF)
182 option(ENABLE_UTILS_ONLY "Build ONLY utils" OFF)
185 option(ENABLE_WRAPPERS "Enable creation of wrapper scripts" ON)
189 # COMMAND git rev-parse --verify -q --short=16 HEAD
192 COMMAND git rev-parse --verify -q HEAD
193 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
194 OUTPUT_VARIABLE GIT_COMMIT_HASH
195 ERROR_VARIABLE GIT_ERROR
196 RESULT_VARIABLE GET_EXEC_RESULT
197 OUTPUT_STRIP_TRAILING_WHITESPACE
200 if(NOT ${GET_EXEC_RESULT} EQUAL 0)
201 set(GIT_COMMIT_HASH "UNKNOWN")
203 if(NOT ${GIT_ERROR} STREQUAL "")
204 set(GIT_COMMIT_HASH "UNKNOWN")
207 if(${GIT_COMMIT_HASH} STREQUAL "")
208 set(GIT_COMMIT_HASH "UNKNOWN")
212 #message(STATUS "hash=" ${GIT_COMMIT_HASH})
213 #message(STATUS "error=" ${GIT_ERROR})
215 #add_definitions("-DVV_GIT_COMMIT_HASH=${GIT_COMMIT_HASH}")
218 if(ENABLE_UTILS_ONLY)
219 set(ENABLE_CLIENT OFF)
220 set(ENABLE_SERVER OFF)
221 set(ENABLE_VCCRUN OFF)
222 set(ENABLE_VCCRUN_ONLY OFF)
224 elseif(ENABLE_VCCRUN_ONLY)
225 #set(WITH_SYS_VORBIS OFF)
226 #set(WITH_LIBMAD OFF)
227 #set(WITH_SYS_FLAC OFF)
228 #set(WITH_SYS_LIBJPG OFF)
229 #set(WITH_SYS_ZLIB OFF)
230 set(ENABLE_CLIENT OFF)
231 set(ENABLE_SERVER OFF)
232 set(ENABLE_MASTER OFF)
233 set(ENABLE_QUERY_DEMO OFF)
234 set(ENABLE_VCCRUN ON)
235 set(ENABLE_MD2FIXER OFF)
237 if (NOT WITH_SYS_VORBIS OR NOT WITH_SYS_FLAC)
238 message(SEND_ERROR "OpenAL, Vorbis and Flac are required")
242 if(NOT ENABLE_CLIENT)
243 if(NOT ENABLE_SERVER)
244 message(STATUS "Neither client, nor server was requested")
245 else(NOT ENABLE_SERVER)
246 message(STATUS "Server-only build, turning off SDL2, OpenGL and OpenAL")
247 endif(NOT ENABLE_SERVER)
251 set(WITH_SYS_VORBIS OFF)
252 set(WITH_SYS_OPUS OFF)
254 set(WITH_SYS_FLAC OFF)
255 endif(NOT ENABLE_CLIENT)
258 if(NOT CMAKE_BUILD_TYPE)
259 set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
262 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++14")
264 if(NOT SDL2_OVERRIDE)
265 check_include_file(SDL2/SDL.h HAVE_SDL2_SUBDIR)
267 #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lSDL2main -lSDL2")
268 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lSDL2")
269 add_definitions(-DVAVOOM_ARCH_LINUX_SPECIAL_SDL=1)
270 endif(HAVE_SDL2_SUBDIR)
271 endif(NOT SDL2_OVERRIDE)
274 add_definitions(-DSDL_MAIN_HANDLED)
278 set(UNFUCK_GCC_FLAGS "")
279 set(UNFUCK_GXX_FLAGS "")
281 if(K8_UNFUCK_AS_SHITLANG)
282 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wno-ignored-optimization-argument")
283 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wno-unused-command-line-argument")
284 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wno-unknown-warning-option")
285 endif(K8_UNFUCK_AS_SHITLANG)
288 #set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Werror=format-security")
289 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fno-aggressive-loop-optimizations")
290 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fcommon") # fuck you, shitcc10
292 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fanalyzer")
294 endif(K8_UNFUCK_AS_GCC)
296 # WARNING! do not touch anything here even if you think you know what you're doing.
297 # any change may and WILL break the code.
298 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fno-delete-null-pointer-checks")
299 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fno-strict-aliasing")
300 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fno-strict-overflow")
301 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fwrapv")
303 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fno-diagnostics-show-caret")
304 endif(K8_UNFUCK_AS_GCC)
305 if(K8_UNFUCK_AS_GCC AND UNIX AND NOT CMAKE_CROSSCOMPILING)
306 # i refuse to upgrade, lol
307 if("$ENV{USER}" STREQUAL "ketmar")
308 set(UNFUCK_GXX_FLAGS "${UNFUCK_GXX_FLAGS} -Wabi=10")
309 set(UNFUCK_GXX_FLAGS "${UNFUCK_GXX_FLAGS} -fabi-version=10")
311 endif(K8_UNFUCK_AS_GCC AND UNIX AND NOT CMAKE_CROSSCOMPILING)
313 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fsigned-char")
314 set(UNFUCK_GXX_FLAGS "${UNFUCK_GXX_FLAGS} -fexceptions")
316 set(UNFUCK_GXX_FLAGS "${UNFUCK_GXX_FLAGS} -frtti")
319 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wall")
320 #set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wno-frame-address")
322 if(NOT WITH_GCC_IDIOCITY)
323 if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 6.0)
324 # k8: fuck you, gcc. i have my own style, gtfo.
325 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wno-misleading-indentation")
326 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wno-ignored-attributes")
328 endif(NOT WITH_GCC_IDIOCITY)
331 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mstackrealign")
332 message(STATUS "enabled stack realign")
333 endif(VV_STACK_REALIGN)
336 add_definitions(-DVCORE_ALLOW_STRTODEX=1)
345 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath -Wl,${RPATH_VALUE}")
348 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Werror=format-security")
349 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wparentheses")
351 if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9.0)
352 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fno-diagnostics-show-line-numbers")
353 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fno-diagnostics-show-labels")
356 if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 6.9)
357 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wimplicit-fallthrough")
358 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wshadow=local")
359 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Walloc-zero")
362 if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.7)
363 #set(UNFUCK_GXX_FLAGS "${UNFUCK_GXX_FLAGS} -Wno-class-memaccess")
364 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wmultistatement-macros")
365 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wmissing-attributes")
366 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wcast-function-type")
367 set(UNFUCK_GXX_FLAGS "${UNFUCK_GXX_FLAGS} -Wsuggest-override")
370 if(WITH_GCC_IDIOCITY)
372 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wextra")
373 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wno-ignored-attributes")
374 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wno-unused-parameter")
375 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wno-misleading-indentation")
376 if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9.0)
377 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wno-address-of-packed-member")
380 if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 6.0)
381 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wno-invalid-memory-model")
383 else(WITH_GCC_IDIOCITY)
385 if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 6.0)
386 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wno-invalid-memory-model")
389 if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9.0)
390 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wno-misleading-indentation")
392 if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9.0)
393 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wno-address-of-packed-member")
395 endif(WITH_GCC_IDIOCITY)
397 set(UNFUCK_GXX_FLAGS "${UNFUCK_GXX_FLAGS} -Wno-old-style-cast")
398 set(UNFUCK_GXX_FLAGS "${UNFUCK_GXX_FLAGS} -Woverloaded-virtual")
399 set(UNFUCK_GXX_FLAGS "${UNFUCK_GXX_FLAGS} -Wsign-promo")
400 set(UNFUCK_GXX_FLAGS "${UNFUCK_GXX_FLAGS} -Wmultiple-inheritance")
401 set(UNFUCK_GXX_FLAGS "${UNFUCK_GXX_FLAGS} -Wvirtual-inheritance")
403 # this protects some shitpp classes from MT code; we don't need this
404 set(UNFUCK_GXX_FLAGS "${UNFUCK_GXX_FLAGS} -fno-threadsafe-statics")
405 # who cares, i don't use std
406 set(UNFUCK_GXX_FLAGS "${UNFUCK_GXX_FLAGS} -fno-use-cxa-get-exception-ptr")
409 ###########################
410 ## some math/FPU options ##
411 ###########################
413 if(NOT DEBUG_FPU_CHECKS AND NOT NSWITCH)
414 # use -ffast-math, 'cause why not?
415 # k8: nope, i command my former self to not do this
416 #set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -ffast-math")
417 if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 6.0)
418 # on gcc 5.x leads to internal compiler errors
419 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fno-math-errno")
421 endif(NOT DEBUG_FPU_CHECKS AND NOT NSWITCH)
424 ##########################################
425 ## unfuck idiotic gcc code downgradizer ##
426 ##########################################
428 # WARNING! do not touch anything here even if you think you know what you're doing.
429 # any change may and WILL break the code.
431 # actually, we don't need strict floating point math compliance, so let's use "-ffast-math"
432 # no, no fuckin' way. with "-ffast-math" not-a-number is EQUAL TO ZERO!
434 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fno-unsafe-math-optimizations")
435 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fno-associative-math")
436 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fno-reciprocal-math")
437 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fno-finite-math-only")
438 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fsigned-zeros")
439 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fsignaling-nans") # do not touch my NaNs!
440 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -frounding-math") # get lost!
441 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -ffp-contract=off") # do not use fused fmadd, even if it is available
442 # we don't need strict standards compliance
443 # note that this may modify NaNs, so if we'll use NaN-boxing, we should put "-fsignaling-nans" after fastmath
444 #set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -ffast-math")
446 # force gcc to unroll some loops
447 set(K8_OPT_GCC_FLAGS "${K8_OPT_GCC_FLAGS} -funroll-loops")
448 set(K8_OPT_GCC_FLAGS "${K8_OPT_GCC_FLAGS} -fpredictive-commoning")
450 # consider more optimisation options (from O3):
452 # -ftree-loop-distribute-patterns
454 # and force gcc to not vectrosize (whatever it is)
455 set(K8_OPT_GCC_FLAGS "${K8_OPT_GCC_FLAGS} -fno-tree-vectorize")
456 set(K8_OPT_GCC_FLAGS "${K8_OPT_GCC_FLAGS} -fvect-cost-model=cheap")
457 set(K8_OPT_GCC_FLAGS "${K8_OPT_GCC_FLAGS} -fsimd-cost-model=cheap")
459 # pointer alias analysis; no wai
460 set(K8_OPT_GCC_FLAGS "${K8_OPT_GCC_FLAGS} -fno-tree-pta")
461 # but allow function inlining
462 set(K8_OPT_GCC_FLAGS "${K8_OPT_GCC_FLAGS} -finline-functions")
463 # duplicate loop invariant branches (whatever it is)
464 #set(K8_OPT_GCC_FLAGS "${K8_OPT_GCC_FLAGS} -funswitch-loops")
466 if("$ENV{USER}" STREQUAL "ketmar")
467 set(K8_NATIVE_ARCH "-march=nehalem")
468 set(K8_NATIVE_TUNE "-mtune=nehalem")
470 set(K8_NATIVE_ARCH "-march=native")
471 set(K8_NATIVE_TUNE "-mtune=native")
476 message(STATUS "BUILD: using FPU")
477 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mfpmath=387")
478 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -ffloat-store")
479 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fsignaling-nans")
480 add_definitions(-DUSE_FPU_MATH=1)
482 message(STATUS "BUILD: using AVX2 instriction set")
483 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} ${K8_NATIVE_ARCH}")
484 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} ${K8_NATIVE_TUNE}")
485 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mavx2")
486 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mfpmath=sse")
488 message(STATUS "BUILD: using SSE4.2 instriction set")
489 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} ${K8_NATIVE_ARCH}")
490 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} ${K8_NATIVE_TUNE}")
491 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -msse4.2")
492 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mno-avx")
493 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mfpmath=sse")
495 message(STATUS "BUILD: using SSE4.1 instriction set")
496 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} ${K8_NATIVE_ARCH}")
497 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} ${K8_NATIVE_TUNE}")
498 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -msse4.1")
499 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mno-avx")
500 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mfpmath=sse")
502 message(STATUS "BUILD: using SSE4 instriction set")
503 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} ${K8_NATIVE_ARCH}")
504 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} ${K8_NATIVE_TUNE}")
505 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -msse4")
506 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mno-avx")
507 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mfpmath=sse")
509 message(STATUS "BUILD: using SSE3 instriction set")
510 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} ${K8_NATIVE_ARCH}")
511 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} ${K8_NATIVE_TUNE}")
512 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -msse3")
513 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mno-avx")
514 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mfpmath=sse")
518 message(STATUS "BUILD: using SSE2/p4 instriction set")
519 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -march=pentium4")
520 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mtune=pentium4")
522 message(STATUS "BUILD: using SSE2/native instriction set")
523 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} ${K8_NATIVE_ARCH}")
524 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} ${K8_NATIVE_TUNE}")
526 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -msse2")
527 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mno-avx")
528 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mfpmath=sse")
530 message(STATUS "BUILD: using SSE2/p4 instriction set")
531 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -march=pentium4")
532 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mtune=pentium4")
533 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -msse2")
534 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mno-avx")
535 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mfpmath=sse")
542 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -pthread")
543 set(CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE} -pthread")
544 set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -pthread")
545 endif(NOT NO_PTHREAD)
547 set(CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE} -mwindows")
548 set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -mwindows")
553 #if(ENABLE_SIGNAL_HANDLER)
554 # set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wno-frame-address")
555 #endif(ENABLE_SIGNAL_HANDLER)
558 if(UNSTABLE_OPTIMISATIONS)
560 message(STATUS "USING UNSTABLE GCC CODE DEGRADIZER OPTIONS!")
561 else(UNSTABLE_OPTIMISATIONS)
563 endif(UNSTABLE_OPTIMISATIONS)
566 ############################
567 ## unfuck all build types ##
568 ############################
569 string(REGEX REPLACE "-O[0-9]" " " CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
570 string(REGEX REPLACE "-O[0-9]" " " CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
572 set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -g ${UNFUCK_GCC_FLAGS}")
573 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g ${UNFUCK_GCC_FLAGS} ${UNFUCK_GXX_FLAGS}")
575 string(REGEX REPLACE "-O[0-9]" " " CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
576 string(REGEX REPLACE "-O[0-9]" " " CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
578 set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${VV_OPTIM} ${UNFUCK_GCC_FLAGS} ${K8_OPT_GCC_FLAGS}")
579 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${VV_OPTIM} ${UNFUCK_GCC_FLAGS} ${UNFUCK_GXX_FLAGS} ${K8_OPT_GCC_FLAGS}")
581 string(REGEX REPLACE "-O[0-9]" " " CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
582 string(REGEX REPLACE "-O[0-9]" " " CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
584 set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} ${VV_OPTIM} -g ${UNFUCK_GCC_FLAGS} ${K8_OPT_GCC_FLAGS}")
585 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${VV_OPTIM} -g ${UNFUCK_GCC_FLAGS} ${UNFUCK_GXX_FLAGS} ${K8_OPT_GCC_FLAGS}")
587 string(REGEX REPLACE "-O[0-9]" " " CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}")
588 string(REGEX REPLACE "-O[0-9]" " " CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}")
590 set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_RELWITHDEBINFO} -Os ${UNFUCK_GCC_FLAGS}")
591 set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -Os ${UNFUCK_GCC_FLAGS} ${UNFUCK_GXX_FLAGS}")
594 add_definitions(-DZDBSP_DISABLE_SSE=1)
596 if(NOT WITH_MIMALLOC)
597 add_definitions(-DVAVOOM_DISABLE_MIMALLOC)
598 message(STATUS "Using system memory allocator")
599 endif(NOT WITH_MIMALLOC)
601 set(VAVOOM_MAIN_DEPS "")
604 set(WINERUN "$ENV{K8VAVOOM_WINE}")
613 ## message(STATUS "BUILD: ${CMAKE_BUILD_TYPE}")
614 ## message(STATUS "cflags : ${CMAKE_C_FLAGS}")
615 ## message(STATUS "cxxflags: ${CMAKE_CXX_FLAGS}")
616 ## message(STATUS "cflags (dbg): ${CMAKE_C_FLAGS_DEBUG}")
617 ## message(STATUS "cxxflags(dbg): ${CMAKE_CXX_FLAGS_DEBUG}")
619 if(NOT DEFINED DATADIR)
620 set(DATADIR share/k8vavoom)
621 endif(NOT DEFINED DATADIR)
622 if(NOT DEFINED BINDIR)
624 endif(NOT DEFINED BINDIR)
625 if(NOT DEFINED SPECSDIR)
627 endif(NOT DEFINED SPECSDIR)
631 # **** Check for inttypes.h ****
633 ### find_path(INTTYPES_INCLUDE_DIR inttypes.h)
634 ### if(INTTYPES_INCLUDE_DIR)
635 ### add_definitions(-DHAVE_INTTYPES_H=1)
636 ### endif(INTTYPES_INCLUDE_DIR)
640 # **** Check for newtwork libraries ****
643 set(NET_LIBRARIES wsock32)
645 set(NET_LIBRARIES "")
650 # **** pkg-config is required ****
652 FIND_PACKAGE(PkgConfig REQUIRED)
656 # **** Check for zlib ****
661 # include_directories(${ZLIB_INCLUDE_DIR})
663 # message(STATUS "WARNING: Zlib not found, using internal zlib")
664 # set(WITH_SYS_ZLIB OFF)
665 # set(ZLIB_LIBRARIES z)
666 # set(VAVOOM_MAIN_DEPS ${VAVOOM_MAIN_DEPS} z)
669 # add_definitions(-DUSE_INTERNAL_ZLIB=1)
670 # add_definitions(-DHAVE_ZLIB_H=1)
671 # message(STATUS "Using built-in zlib")
672 # set(ZLIB_LIBRARIES "z")
673 # set(VAVOOM_MAIN_DEPS ${VAVOOM_MAIN_DEPS} z)
674 #endif(WITH_SYS_ZLIB)
675 #set(MAIN_LIBS z ${MAIN_LIBS})
679 # **** Check for libjpeg ****
681 if(ENABLE_CLIENT OR ENABLE_SERVER OR ENABLE_VCCRUN)
684 add_definitions(-DVAVOOM_DISABLE_STB_IMAGE_JPEG=1)
688 include_directories(${JPEG_INCLUDE_DIR})
689 set(MAIN_LIBS ${JPEG_LIBRARIES} ${MAIN_LIBS})
690 add_definitions(-DVAVOOM_USE_LIBJPG=1)
692 message(STATUS "WARNING: LibJpeg not found, using internal jpeg reader")
693 set(WITH_SYS_LIBJPG OFF)
695 endif(WITH_SYS_LIBJPG)
697 if(NOT WITH_SYS_LIBJPG)
698 set(MAIN_LIBS jpeg ${MAIN_LIBS})
699 set(VAVOOM_MAIN_DEPS ${VAVOOM_MAIN_DEPS} jpeg)
700 endif(NOT WITH_SYS_LIBJPG)
702 endif(ENABLE_CLIENT OR ENABLE_SERVER OR ENABLE_VCCRUN)
706 # **** Check for liblzma ****
709 # find_package(LibLZMA)
711 # include_directories(${LIBLZMA_INCLUDE_DIRS})
712 # #message(STATUS "***: " ${LIBLZMA_INCLUDE_DIRS})
713 # #message(STATUS "***: " ${LIBLZMA_LIBRARIES})
714 # set(MAIN_LIBS ${LIBLZMA_LIBRARIES} ${MAIN_LIBS})
715 # else(LIBLZMA_FOUND)
716 # message(STATUS "WARNING: LibLzma not found, using internal lzma decoder")
717 # set(WITH_SYS_LZMA OFF)
718 # endif(LIBLZMA_FOUND)
719 #endif(WITH_SYS_LZMA)
721 #if(NOT WITH_SYS_LZMA)
722 # set(MAIN_LIBS lzma ${MAIN_LIBS})
723 # set(VAVOOM_MAIN_DEPS ${VAVOOM_MAIN_DEPS} lzma)
724 # add_definitions(-DUSE_INTERNAL_LZMA=1)
725 #endif(NOT WITH_SYS_LZMA)
727 #if(NOT WITH_SYS_LZMA)
728 # message(STATUS "LZMA: using internal liblzma")
729 # set(LIBLZMA_LIBRARIES "lzma")
730 # add_definitions(-DUSE_INTERNAL_LZMA=1)
731 #endif(NOT WITH_SYS_LZMA)
735 # **** Check for OpenAL ****
737 if(ENABLE_CLIENT OR ENABLE_VCCRUN)
740 message(FATAL_ERROR "WITH_SDL2 required for MojoAL")
742 #check_include_file(SDL2/SDL_mixer.h HAVE_SDL2_SUBDIR)
743 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lSDL2_mixer")
744 add_definitions(-DVAVOOM_USE_MOJOAL=1)
746 find_package(OpenAL REQUIRED)
747 include_directories(${OPENAL_INCLUDE_DIR})
748 if(WITH_STATIC_OPENAL)
749 #k8: my MXE builds are static. live with it.
750 add_definitions(-DAL_LIBTYPE_STATIC=1)
751 endif(WITH_STATIC_OPENAL)
752 set(MAIN_LIBS ${OPENAL_LIBRARY} ${MAIN_LIBS})
754 set(MAIN_LIBS ${OPENAL_LIBRARY} winmm ${MAIN_LIBS})
757 endif(ENABLE_CLIENT OR ENABLE_VCCRUN)
760 set(VAVOOM_SHITDOZE_LIBS winmm setupapi samplerate)
762 set(VAVOOM_SHITDOZE_LIBS )
765 set(MAIN_LIBS ${VAVOOM_SHITDOZE_LIBS} ${MAIN_LIBS})
767 set(NEED_SYS_OGG OFF)
770 endif(WITH_SYS_VORBIS)
777 # **** Check for libogg ****
780 PKG_CHECK_MODULES(OGG ogg)
782 message(STATUS "Found libogg: ${OGG_LIBRARIES}")
783 include_directories(${OGG_INCLUDE_DIRS})
784 set(MAIN_LIBS ${OGG_LIBRARIES} ${MAIN_LIBS})
790 # **** Check for Vorbis ****
793 PKG_CHECK_MODULES(VORBIS vorbis)
794 if(OGG_FOUND AND VORBIS_FOUND)
795 message(STATUS "Found Vorbis: ${VORBIS_LIBRARIES}")
797 include_directories(${VORBIS_INCLUDE_DIRS})
798 set(MAIN_LIBS ${VORBIS_LIBRARIES} ${MAIN_LIBS})
799 else(OGG_FOUND AND VORBIS_FOUND)
800 message(STATUS "Could NOT find OggVorbis libraries")
801 set(VORBIS_FOUND OFF)
802 message(FATAL_ERROR "You need libvorbis to compile k8vavoom.")
804 endif(OGG_FOUND AND VORBIS_FOUND)
805 else(WITH_SYS_VORBIS)
806 set(VORBIS_FOUND OFF)
807 message(STATUS "using stb_vorbis for Ogg/Vorbis decoding")
808 endif(WITH_SYS_VORBIS)
812 # **** Check for Opus ****
814 set(OPUS_USE_INTERNAL OFF)
816 PKG_CHECK_MODULES(OPUS opusfile opus)
817 if(OPUS_FOUND AND OGG_FOUND)
818 message(STATUS "Found Opus: ${OPUS_LIBRARIES}")
820 include_directories(${OPUS_INCLUDE_DIRS})
821 set(MAIN_LIBS ${OPUS_LIBRARIES} ${MAIN_LIBS})
822 else(OPUS_FOUND AND OGG_FOUND)
823 message(STATUS "Could NOT find Opus libraries")
825 message(FATAL_ERROR "You need libopus to compile k8vavoom.")
827 endif(OPUS_FOUND AND OGG_FOUND)
830 set(OPUS_USE_INTERNAL ON)
831 include_directories(${CMAKE_SOURCE_DIR}/libs/opus/libopus/include)
832 include_directories(${CMAKE_SOURCE_DIR}/libs/opus/libopusfile/include)
834 set(MAIN_LIBS opusfile opus ${MAIN_LIBS})
835 message(STATUS "using built-in libopus and system libogg")
837 # use built-in libogg
838 include_directories(${CMAKE_SOURCE_DIR}/libs/opus/libogg/include)
839 set(MAIN_LIBS opusfile opus ogg ${MAIN_LIBS})
840 add_definitions(-DVV_BUILTIN_OGG)
841 message(STATUS "using built-in libopus and libogg")
843 add_definitions(-DVV_BUILTIN_OPUS)
849 if(ENABLE_CLIENT OR ENABLE_VCCRUN_ONLY OR ENABLE_VCCRUN)
850 set(XMPLITE_FOUND ON)
851 set(MAIN_LIBS xmplite ${MAIN_LIBS})
852 include_directories(libs/xmplite)
853 add_definitions(-DLIBXMP_CORE_PLAYER)
854 add_definitions(-DXMP_SYM_VISIBILITY)
855 endif(ENABLE_CLIENT OR ENABLE_VCCRUN_ONLY OR ENABLE_VCCRUN)
859 # **** Check for libmad ****
862 find_path(MAD_INCLUDE_DIRS mad.h)
863 find_library(MAD_LIBRARIES NAMES mad)
865 message(STATUS "Found LibMAD: ${MAD_LIBRARIES}")
867 include_directories(${MAD_INCLUDE_DIRS})
868 set(MAIN_LIBS ${MAD_LIBRARIES} ${MAIN_LIBS})
870 message(STATUS "Could NOT find LibMAD libraries")
871 set(LIBMAD_FOUND OFF)
874 set(LIBMAD_FOUND OFF)
875 message(STATUS "using dr_mp3 for MP3 decoding")
880 # **** Check for FLAC ****
883 PKG_CHECK_MODULES(FLAC flac)
885 message(STATUS "Found FLAC: ${FLAC_LIBRARIES}")
886 include_directories(${FLAC_INCLUDE_DIRS})
887 set(MAIN_LIBS ${FLAC_LIBRARIES} ${MAIN_LIBS})
889 message(STATUS "Could NOT find FLAC library")
894 message(STATUS "using dr_flac for FLAC decoding")
899 # **** Check for LibJIT ****
902 PKG_CHECK_MODULES(LIBJIT libjit)
904 message(STATUS "Found LibJIT: ${LIBJIT_LIBRARIES}")
905 include_directories(${LIBJIT_INCLUDE_DIRS})
906 set(MAIN_LIBS ${LIBJIT_LIBRARIES} ${MAIN_LIBS})
908 message(STATUS "Could not find LibJIT library (this is OK)")
909 set(LIBJIT_FOUND OFF)
912 set(LIBJIT_FOUND OFF)
913 #message(STATUS "LibJIT disabled by user")
917 add_definitions(-DUSE_LIBJIT)
922 # **** Check for FluidSynth ****
924 if(WITH_FLUID AND ENABLE_CLIENT)
926 PKG_CHECK_MODULES(FLUID fluidsynth)
927 #message(STATUS, "FINC:" ${FLUID_INCLUDE_DIRS})
928 #message(STATUS, "FLIB:" ${FLUID_LIBRARIES})
929 if(WIN32 AND FLUID_FOUND)
930 PKG_CHECK_MODULES(GLIB glib-2.0)
932 include_directories(${GLIB_INCLUDE_DIRS})
933 set(MAIN_LIBS ${GLIB_LIBRARIES} ${MAIN_LIBS})
937 endif(WIN32 AND FLUID_FOUND)
939 message(STATUS "Found FluidSynth: ${FLUID_LIBRARIES}")
941 include_directories(${FLUID_INCLUDE_DIRS})
942 set(MAIN_LIBS ${FLUID_LIBRARIES} ${MAIN_LIBS})
943 else(FLUID_INCLUDE_DIRS AND FLUID_LIBRARIES)
944 message(STATUS "Could NOT find FluidSynth libraries")
946 message(STATUS "Using built-in FluidSynth")
947 set(WITH_SYS_FLUID OFF)
952 message(STATUS "Using built-in FluidSynth")
954 endif(WITH_SYS_FLUID)
957 endif(WITH_FLUID AND ENABLE_CLIENT)
959 if(FLUID_FOUND AND NOT WITH_SYS_FLUID AND ENABLE_CLIENT)
960 add_definitions(-DBUILTIN_FLUID)
961 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libs/fluidsynth_lite/include)
962 include_directories(${CMAKE_CURRENT_BINARY_DIR}/libs/fluidsynth_lite/include)
963 set(MAIN_LIBS libfluidsynth_lite ${MAIN_LIBS})
964 endif(FLUID_FOUND AND NOT WITH_SYS_FLUID AND ENABLE_CLIENT)
968 # **** Platform specific library checks ****
971 # ---------------- Other *NIX platforms ----------------
973 if(CMAKE_CROSSCOMPILING AND ANDROID)
974 if(SDL2_INCLUDE_DIRS STREQUAL "")
975 message(FATAL_ERROR "SDL2_INCLUDE_DIRS not specified")
977 if(SDL2_LIBRARIES STREQUAL "")
978 message(FATAL_ERROR "SDL2_LIBRARIES not specified")
982 find_package(SDL2 REQUIRED)
983 #PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2)
985 include_directories(${SDL2_INCLUDE_DIRS})
986 set(MAIN_LIBS ${SDL2_LIBRARIES} ${MAIN_LIBS})
987 #message(STATUS "SDL2 INCLUDES:" ${SDL2_INCLUDE_DIRS})
988 #message(STATUS "SDL2 LIBS:" ${SDL2_LIBRARIES})
990 set(OPENGL_FOUND OFF)
996 message(SEND_ERROR "SDL2 required for OpenGL")
999 set(OpenGL_GL_PREFERENCE LEGACY)
1001 # massive fucking hack because nothing works right
1002 set(OPENGL_gl_LIBRARY "-L$ENV{PORTLIBS_PREFIX}/lib -lEGL -lglapi -ldrm_nouveau")
1003 set(OPENGL_INCLUDE_DIR "$ENV{PORTLIBS_PREFIX}/include")
1004 set(OPENGL_FOUND ON)
1006 set(OPENGL_gl_LIBRARY "-L${GL4ES_LIBRARY_DIR} -lGL")
1007 set(OPENGL_INCLUDE_DIR "${GL4ES_INCLUDE_DIR}")
1008 set(OPENGL_FOUND ON)
1010 find_package(OpenGL REQUIRED)
1013 message(STATUS "Found OpenGL")
1014 include_directories(${OPENGL_INCLUDE_DIR})
1015 if(NSWITCH OR WITH_GL4ES)
1016 # have to reorder this shit or else it doesn't link
1017 set(MAIN_LIBS ${MAIN_LIBS} ${OPENGL_gl_LIBRARY})
1019 set(MAIN_LIBS ${OPENGL_gl_LIBRARY} ${MAIN_LIBS})
1023 set(OPENGL_FOUND OFF)
1029 add_definitions(-DGL4ES_HACKS)
1032 add_definitions(-DGL4ES_NO_CONSTRUCTOR)
1037 add_definitions(-UDEBUG)
1038 set(MAIN_LIBS log android ${MAIN_LIBS})
1042 add_definitions(-DUSE_GLAD=1)
1043 if(GLAD_INCLUDE_DIR AND GLAD_LIBRARY)
1044 include_directories(${GLAD_INCLUDE_DIR})
1045 set(MAIN_LIBS ${GLAD_LIBRARY} ${MAIN_LIBS})
1046 else(GLAD_INCLUDE_DIR AND GLAD_LIBRARY)
1047 include_directories("libs/glad")
1048 set(MAIN_LIBS glad ${MAIN_LIBS})
1049 set(VAVOOM_MAIN_DEPS ${VAVOOM_MAIN_DEPS} glad)
1050 endif(GLAD_INCLUDE_DIR AND GLAD_LIBRARY)
1058 message(STATUS "Building for Switch")
1059 include_directories("$ENV{DEVKITPRO}/libnx/include")
1060 include_directories("$ENV{PORTLIBS_PREFIX}/include")
1061 add_definitions(-D__SWITCH__)
1062 # add libnx at the end of lib list
1063 set(MAIN_LIBS ${MAIN_LIBS} "-L$ENV{PORTLIBS_PREFIX}/lib -lnx")
1064 message(STATUS "Libs: ${MAIN_LIBS}")
1065 # why the fuck does this not work properly in the toolchain file
1066 set(CMAKE_C_COMPILER "aarch64-none-elf-gcc")
1067 set(CMAKE_CXX_COMPILER "aarch64-none-elf-g++")
1068 set(CMAKE_AR "aarch64-none-elf-gcc-ar")
1069 set(CMAKE_RANLIB "aarch64-none-elf-gcc-ranlib")
1070 # enable necessary switches
1077 set(WITH_MIMALLOC OFF)
1078 # turn on nxlink if necessary
1080 add_definitions(-DSWITCH_NXLINK=1)
1085 # # find_package(GnuTLS)
1086 # # if(GNUTLS_FOUND)
1087 # # include_directories(${GNUTLS_INCLUDE_DIR})
1088 # # set(MAIN_LIBS ${GNUTLS_LIBRARIES} ${MAIN_LIBS})
1089 # # add_definitions(${GNUTLS_DEFINITIONS})
1090 # # add_definitions(-DUSE_GNU_TLS)
1091 # # endif(GNUTLS_FOUND)
1094 PKG_CHECK_MODULES(GNUTLS gnutls)
1096 #message(STATUS "GnuTLS INC: " ${GNUTLS_INCLUDE_DIR})
1097 #message(STATUS "GnuTLS LIB: " ${GNUTLS_LIBRARIES})
1098 #message(STATUS "GnuTLS DEF: " ${GNUTLS_DEFINITIONS})
1099 include_directories(${GNUTLS_INCLUDE_DIR})
1100 set(MAIN_LIBS ${GNUTLS_LIBRARIES} ${MAIN_LIBS})
1101 add_definitions(${GNUTLS_DEFINITIONS})
1102 add_definitions(-DUSE_GNU_TLS)
1104 endif(ENABLE_VCCRUN)
1112 PKG_CHECK_MODULES(XRANDR xrandr)
1113 PKG_CHECK_MODULES(X11 x11)
1114 if(XRANDR_FOUND AND X11_FOUND)
1115 message(STATUS "Found XRandR: ${XRANDR_LIBRARIES}")
1116 include_directories(${XRANDR_INCLUDE_DIRS})
1117 include_directories(${X11_INCLUDE_DIRS})
1118 set(MAIN_LIBS ${X11_LIBRARIES} ${XRANDR_LIBRARIES} ${MAIN_LIBS})
1119 add_definitions(-DUSE_XRANDR=1)
1120 else(XRANDR_FOUND AND X11_FOUND)
1121 message(STATUS "Could NOT find XRandR")
1122 endif(XRANDR_FOUND AND X11_FOUND)
1123 #add_definitions(-DUSE_XRANDR=1)
1124 #set(MAIN_LIBS xrandr X11 Xrandr ${MAIN_LIBS})
1129 add_definitions(-DNO_SSE=1)
1133 add_definitions(-DNO_PTHREAD=1)
1137 add_definitions(-DNO_SINCOS=1)
1141 add_definitions(-DNO_SIGNALS=1)
1145 add_definitions(-DNO_SYSCONF=1)
1149 add_definitions(-DNO_MEMRCHR=1)
1153 add_definitions(-DNO_RAWTTY=1)
1156 ### if(CMAKE_EXECUTABLE_FORMAT STREQUAL "ELF")
1157 ### add_subdirectory(libs/libbacktrace)
1158 ### #include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libbacktrace)
1159 ### set(MAIN_LIBS backtrace ${MAIN_LIBS})
1160 ### add_definitions(-DHAVE_BACKTRACE=1)
1164 message(STATUS "=== BUILD OPTIONS ===")
1165 message(STATUS "BUILD: ${CMAKE_BUILD_TYPE}")
1167 message(STATUS "WINE COMMAND: " ${WINERUN})
1169 #message(STATUS "cflags : ${CMAKE_C_FLAGS}")
1170 #message(STATUS "cxxflags: ${CMAKE_CXX_FLAGS}")
1172 message(STATUS "=== COMPONENTS ===")
1173 message(STATUS " Vavoom Client: " ${ENABLE_CLIENT})
1174 message(STATUS " Vavoom Server: " ${ENABLE_SERVER})
1175 message(STATUS " Vavoom Master: " ${ENABLE_MASTER})
1176 message(STATUS " Vavoom Query : " ${ENABLE_QUERY_DEMO})
1177 message(STATUS " VccRun : " ${ENABLE_VCCRUN})
1178 message(STATUS " strtodEx : " ${WITH_STRTODEX})
1181 message(STATUS " GNUTLS : ON")
1183 endif(ENABLE_VCCRUN)
1185 message(STATUS "SDL2 override mode")
1187 if(NOT HAVE_SDL2_SUBDIR)
1188 message(STATUS "SDL2 non-subdir mode")
1189 endif(NOT HAVE_SDL2_SUBDIR)
1190 endif(SDL2_OVERRIDE)
1193 add_subdirectory(libs)
1195 if(ENABLE_UTILS_ONLY)
1196 add_subdirectory(utils)
1197 elseif(NOT ENABLE_VCCRUN_ONLY)
1198 if(NOT CMAKE_CROSSCOMPILING OR WIN32)
1199 add_subdirectory(utils)
1200 endif(NOT CMAKE_CROSSCOMPILING OR WIN32)
1201 add_subdirectory(source)
1202 if(NOT CMAKE_CROSSCOMPILING OR WIN32)
1203 #add_subdirectory(progs)
1204 add_subdirectory(basev)
1205 endif(NOT CMAKE_CROSSCOMPILING OR WIN32)
1206 #foreach(DIR ${EXTRA_SUBDIRS})
1207 # add_subdirectory(${DIR})
1212 add_subdirectory(vccrun)
1213 endif(ENABLE_VCCRUN)