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_SSE2 "Use SSE2 instruction set (may not compile)" OFF)
56 option(WITH_SSE3 "Use SSE3 instruction set (may not compile)" OFF)
57 option(WITH_SSE4 "Use SSE4 instruction set (may not compile)" OFF)
58 option(WITH_SSE41 "Use SSE4.1 instruction set (may not compile)" OFF)
59 option(WITH_SSE42 "Use SSE4.2 instruction set (may not compile)" OFF)
60 option(NO_SSE "Disable all SSE instructions" OFF)
61 option(INSANE_AVX "Use AVX2 instruction set (don't do this, it won't give you any noticeable speedup and may be broken)" OFF)
63 # do not tempt poor things
64 if("$ENV{USER}" STREQUAL "ketmar")
65 option(WITH_GCC_ANAL "Turn on gcc10 static analyzer" OFF)
66 option(WITH_GCC_IDIOCITY "Turn on gcc idiotic pseudo-warnings (don't care, won't fix)" OFF)
68 set(WITH_GCC_ANAL OFF)
69 set(WITH_GCC_IDIOCITY OFF)
72 option(WITH_GLAD "Use supplied GLAD for GL bindings" OFF)
73 option(NO_PTHREAD "Disable pthreads, use C11 threads instead" OFF)
74 option(NO_MEMRCHR "Disable usage of memrchr()" OFF)
75 option(NO_RAWTTY "Disable raw TTY control" OFF)
77 option(WITH_STRTODEX "Use internal strtod implementation to parse floats" ON)
79 # do not tempt poor things
80 if("$ENV{USER}" STREQUAL "ketmar")
81 option(DEBUG_FPU_CHECKS "Use FPU and turn on some checks (GNU/Linux only)" OFF)
82 option(UNSTABLE_OPTIMISATIONS "Use -O3 (WARNING! DON'T DO THAT! NEVER!)" OFF)
84 set(DEBUG_FPU_CHECKS OFF)
85 set(UNSTABLE_OPTIMISATIONS OFF)
88 if(CMAKE_CROSSCOMPILING AND WIN32)
89 option(SDL2_OVERRIDE "Some specific changes for custom-built SDL2 (do not turn on if you don't know what it is)" ON)
90 else(CMAKE_CROSSCOMPILING AND WIN32)
91 option(SDL2_OVERRIDE "Some specific changes for custom-built SDL2 (do not turn on if you don't know what it is)" OFF)
92 endif(CMAKE_CROSSCOMPILING AND WIN32)
94 if(CMAKE_CROSSCOMPILING AND WIN32)
96 option(WITH_WINE "Use wine to run built executables" ON)
97 option(WITH_STATIC_OPENAL "Use special flags to link with static OpenAL" ON)
100 endif(CMAKE_CROSSCOMPILING AND WIN32)
103 option(WITH_NXLINK "Redirect standard output to NXLink" OFF)
104 set(NO_SSE ON) # set it right away for proper logging and cflags
105 set(WITH_MIMALLOC OFF)
108 option(FOSSIL_REPO_PATH "Local path to k8vavoom Fossil repository (leave empty if unsure)" OFF)
113 set(WITH_MIMALLOC OFF)
116 # perform some platform and compiler checks
117 set(VV_STACK_REALIGN OFF)
118 if(CMAKE_CROSSCOMPILING AND WIN32)
119 # cross-compiling to shitdoze
120 message(STATUS "Cross-compiling to shitdoze...")
121 elseif(CMAKE_CROSSCOMPILING)
122 # cross-compiling to something else, let's play safe
123 message(STATUS "Turning off SSE and mi-malloc")
125 set(WITH_MIMALLOC OFF)
126 elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(i[0-9]86|x86|X86|amd64|AMD64|x86_64)")
128 #if(CMAKE_SIZEOF_VOID_P EQUAL 8)
129 # set(OPUS_CPU_X64 1)
131 # set(OPUS_CPU_X86 1)
133 set(VV_STACK_REALIGN ON)
134 #elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(arm|aarch64)")
135 # set(OPUS_CPU_ARM 1)
137 # compiling to something else, let's play safe
138 add_definitions(-DVV_NOT_X86)
139 message(STATUS "Turning off SSE and mi-malloc")
141 set(WITH_MIMALLOC OFF)
144 set( RES_FLAGS -Fpe-i386 )
147 message(STATUS "*** 64-bit builds are UNSUPPORTED ***")
148 add_definitions(-DSTK_TIMET_FIX)
149 set( RES_FLAGS -Fpe-x86-64 )
152 set(K8_UNFUCK_AS_GCC ON)
153 set(K8_UNFUCK_AS_SHITLANG OFF)
154 if(NOT CMAKE_COMPILER_IS_GNUCC)
155 if (APPLE OR CMAKE_HOST_APPLE OR XCODE_VERSION)
156 message(FATAL_ERROR "Apple platform is not supported.")
158 endif(APPLE OR CMAKE_HOST_APPLE OR XCODE_VERSION)
160 if (MSVC OR MSVC80 OR MSVC_IDE)
161 message(FATAL_ERROR "m$ compilers aren't supported. GTFO.")
163 endif(MSVC OR MSVC80 OR MSVC_IDE)
165 message(WARNING "Only GNU C/C++ compilers are supported to build k8vavoom and tools!")
166 message(WARNING "Your compiler is not GNU, please, don't report bugs.")
167 set(K8_UNFUCK_AS_GCC OFF)
169 if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
170 message(WARNING "And, by the way. clang sux.")
171 set(K8_UNFUCK_AS_SHITLANG ON)
173 endif(NOT CMAKE_COMPILER_IS_GNUCC)
175 option(ENABLE_CLIENT "Build client executable" ON)
176 option(ENABLE_SERVER "Build dedicated server executable (don't do that!)" OFF)
177 option(ENABLE_MASTER "Build master server (no reason to build it)" OFF)
178 option(ENABLE_QUERY_DEMO "Build query demo (can be used to send rcon commands)" OFF)
179 option(ENABLE_VCCRUN "Build vccrun executable" OFF)
180 option(ENABLE_MD2FIXER "Build fixmd2 executable (you don't need it)" OFF)
182 option(ENABLE_VCCRUN_ONLY "Build ONLY vccrun" OFF)
183 option(ENABLE_UTILS_ONLY "Build ONLY utils" OFF)
186 option(ENABLE_WRAPPERS "Enable creation of wrapper scripts" ON)
190 # COMMAND git rev-parse --verify -q --short=16 HEAD
193 COMMAND git rev-parse --verify -q HEAD
194 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
195 OUTPUT_VARIABLE GIT_COMMIT_HASH
196 ERROR_VARIABLE GIT_ERROR
197 RESULT_VARIABLE GET_EXEC_RESULT
198 OUTPUT_STRIP_TRAILING_WHITESPACE
201 if(NOT ${GET_EXEC_RESULT} EQUAL 0)
202 set(GIT_COMMIT_HASH "UNKNOWN")
204 if(NOT ${GIT_ERROR} STREQUAL "")
205 set(GIT_COMMIT_HASH "UNKNOWN")
208 if(${GIT_COMMIT_HASH} STREQUAL "")
209 set(GIT_COMMIT_HASH "UNKNOWN")
213 #message(STATUS "hash=" ${GIT_COMMIT_HASH})
214 #message(STATUS "error=" ${GIT_ERROR})
216 #add_definitions("-DVV_GIT_COMMIT_HASH=${GIT_COMMIT_HASH}")
219 if(ENABLE_UTILS_ONLY)
220 set(ENABLE_CLIENT OFF)
221 set(ENABLE_SERVER OFF)
222 set(ENABLE_VCCRUN OFF)
223 set(ENABLE_VCCRUN_ONLY OFF)
225 elseif(ENABLE_VCCRUN_ONLY)
226 #set(WITH_SYS_VORBIS OFF)
227 #set(WITH_LIBMAD OFF)
228 #set(WITH_SYS_FLAC OFF)
229 #set(WITH_SYS_LIBJPG OFF)
230 #set(WITH_SYS_ZLIB OFF)
231 set(ENABLE_CLIENT OFF)
232 set(ENABLE_SERVER OFF)
233 set(ENABLE_MASTER OFF)
234 set(ENABLE_QUERY_DEMO OFF)
235 set(ENABLE_VCCRUN ON)
236 set(ENABLE_MD2FIXER OFF)
238 if (NOT WITH_SYS_VORBIS OR NOT WITH_SYS_FLAC)
239 message(SEND_ERROR "OpenAL, Vorbis and Flac are required")
243 if(NOT ENABLE_CLIENT)
244 if(NOT ENABLE_SERVER)
245 message(STATUS "Neither client, nor server was requested")
246 else(NOT ENABLE_SERVER)
247 message(STATUS "Server-only build, turning off SDL2, OpenGL and OpenAL")
248 endif(NOT ENABLE_SERVER)
252 set(WITH_SYS_VORBIS OFF)
253 set(WITH_SYS_OPUS OFF)
255 set(WITH_SYS_FLAC OFF)
256 endif(NOT ENABLE_CLIENT)
259 if(NOT CMAKE_BUILD_TYPE)
260 set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
263 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++14")
265 if(NOT SDL2_OVERRIDE)
266 check_include_file(SDL2/SDL.h HAVE_SDL2_SUBDIR)
268 #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lSDL2main -lSDL2")
269 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lSDL2")
270 add_definitions(-DVAVOOM_ARCH_LINUX_SPECIAL_SDL=1)
271 endif(HAVE_SDL2_SUBDIR)
272 endif(NOT SDL2_OVERRIDE)
275 add_definitions(-DSDL_MAIN_HANDLED)
279 set(UNFUCK_GCC_FLAGS "")
280 set(UNFUCK_GXX_FLAGS "")
282 if(K8_UNFUCK_AS_SHITLANG)
283 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wno-ignored-optimization-argument")
284 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wno-unused-command-line-argument")
285 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wno-unknown-warning-option")
286 endif(K8_UNFUCK_AS_SHITLANG)
289 #set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Werror=format-security")
290 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fno-aggressive-loop-optimizations")
291 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fcommon") # fuck you, shitcc10
293 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fanalyzer")
295 endif(K8_UNFUCK_AS_GCC)
297 # WARNING! do not touch anything here even if you think you know what you're doing.
298 # any change may and WILL break the code.
299 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fno-delete-null-pointer-checks")
300 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fno-strict-aliasing")
301 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fno-strict-overflow")
302 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fwrapv")
304 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fno-diagnostics-show-caret")
305 endif(K8_UNFUCK_AS_GCC)
306 if(K8_UNFUCK_AS_GCC AND UNIX AND NOT CMAKE_CROSSCOMPILING)
307 # i refuse to upgrade, lol
308 if("$ENV{USER}" STREQUAL "ketmar")
309 set(UNFUCK_GXX_FLAGS "${UNFUCK_GXX_FLAGS} -Wabi=10")
310 set(UNFUCK_GXX_FLAGS "${UNFUCK_GXX_FLAGS} -fabi-version=10")
312 endif(K8_UNFUCK_AS_GCC AND UNIX AND NOT CMAKE_CROSSCOMPILING)
314 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fsigned-char")
315 set(UNFUCK_GXX_FLAGS "${UNFUCK_GXX_FLAGS} -fexceptions")
317 set(UNFUCK_GXX_FLAGS "${UNFUCK_GXX_FLAGS} -frtti")
320 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wall")
321 #set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wno-frame-address")
323 if(NOT WITH_GCC_IDIOCITY)
324 if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 6.0)
325 # k8: fuck you, gcc. i have my own style, gtfo.
326 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wno-misleading-indentation")
327 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wno-ignored-attributes")
329 endif(NOT WITH_GCC_IDIOCITY)
332 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mstackrealign")
333 message(STATUS "enabled stack realign")
334 endif(VV_STACK_REALIGN)
337 add_definitions(-DVCORE_ALLOW_STRTODEX=1)
346 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath -Wl,${RPATH_VALUE}")
349 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Werror=format-security")
350 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wparentheses")
352 if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9.0)
353 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fno-diagnostics-show-line-numbers")
354 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fno-diagnostics-show-labels")
357 if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 6.9)
358 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wimplicit-fallthrough")
359 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wshadow=local")
360 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Walloc-zero")
363 if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.7)
364 #set(UNFUCK_GXX_FLAGS "${UNFUCK_GXX_FLAGS} -Wno-class-memaccess")
365 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wmultistatement-macros")
366 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wmissing-attributes")
367 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wcast-function-type")
368 set(UNFUCK_GXX_FLAGS "${UNFUCK_GXX_FLAGS} -Wsuggest-override")
371 if(WITH_GCC_IDIOCITY)
373 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wextra")
374 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wno-ignored-attributes")
375 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wno-unused-parameter")
376 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wno-misleading-indentation")
377 if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9.0)
378 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wno-address-of-packed-member")
381 if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 6.0)
382 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wno-invalid-memory-model")
384 else(WITH_GCC_IDIOCITY)
386 if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 6.0)
387 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wno-invalid-memory-model")
390 if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9.0)
391 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wno-misleading-indentation")
393 if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9.0)
394 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wno-address-of-packed-member")
396 endif(WITH_GCC_IDIOCITY)
398 set(UNFUCK_GXX_FLAGS "${UNFUCK_GXX_FLAGS} -Wno-old-style-cast")
399 set(UNFUCK_GXX_FLAGS "${UNFUCK_GXX_FLAGS} -Woverloaded-virtual")
400 set(UNFUCK_GXX_FLAGS "${UNFUCK_GXX_FLAGS} -Wsign-promo")
401 set(UNFUCK_GXX_FLAGS "${UNFUCK_GXX_FLAGS} -Wmultiple-inheritance")
402 set(UNFUCK_GXX_FLAGS "${UNFUCK_GXX_FLAGS} -Wvirtual-inheritance")
404 # this protects some shitpp classes from MT code; we don't need this
405 set(UNFUCK_GXX_FLAGS "${UNFUCK_GXX_FLAGS} -fno-threadsafe-statics")
406 # who cares, i don't use std
407 set(UNFUCK_GXX_FLAGS "${UNFUCK_GXX_FLAGS} -fno-use-cxa-get-exception-ptr")
410 ###########################
411 ## some math/FPU options ##
412 ###########################
414 if(NOT DEBUG_FPU_CHECKS AND NOT NSWITCH)
415 # use -ffast-math, 'cause why not?
416 # k8: nope, i command my former self to not do this
417 #set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -ffast-math")
418 if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 6.0)
419 # on gcc 5.x leads to internal compiler errors
420 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fno-math-errno")
422 endif(NOT DEBUG_FPU_CHECKS AND NOT NSWITCH)
425 ##########################################
426 ## unfuck idiotic gcc code downgradizer ##
427 ##########################################
429 # WARNING! do not touch anything here even if you think you know what you're doing.
430 # any change may and WILL break the code.
432 # actually, we don't need strict floating point math compliance, so let's use "-ffast-math"
433 # no, no fuckin' way. with "-ffast-math" not-a-number is EQUAL TO ZERO!
435 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fno-unsafe-math-optimizations")
436 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fno-associative-math")
437 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fno-reciprocal-math")
438 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fno-finite-math-only")
439 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fsigned-zeros")
440 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fsignaling-nans") # do not touch my NaNs!
441 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -frounding-math") # get lost!
442 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -ffp-contract=off") # do not use fused fmadd, even if it is available
443 # we don't need strict standards compliance
444 # note that this may modify NaNs, so if we'll use NaN-boxing, we should put "-fsignaling-nans" after fastmath
445 #set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -ffast-math")
447 # force gcc to unroll some loops
448 set(K8_OPT_GCC_FLAGS "${K8_OPT_GCC_FLAGS} -funroll-loops")
449 set(K8_OPT_GCC_FLAGS "${K8_OPT_GCC_FLAGS} -fpredictive-commoning")
451 # consider more optimisation options (from O3):
453 # -ftree-loop-distribute-patterns
455 # and force gcc to not vectrosize (whatever it is)
456 set(K8_OPT_GCC_FLAGS "${K8_OPT_GCC_FLAGS} -fno-tree-vectorize")
457 set(K8_OPT_GCC_FLAGS "${K8_OPT_GCC_FLAGS} -fvect-cost-model=cheap")
458 set(K8_OPT_GCC_FLAGS "${K8_OPT_GCC_FLAGS} -fsimd-cost-model=cheap")
460 # pointer alias analysis; no wai
461 set(K8_OPT_GCC_FLAGS "${K8_OPT_GCC_FLAGS} -fno-tree-pta")
462 # but allow function inlining
463 set(K8_OPT_GCC_FLAGS "${K8_OPT_GCC_FLAGS} -finline-functions")
464 # duplicate loop invariant branches (whatever it is)
465 #set(K8_OPT_GCC_FLAGS "${K8_OPT_GCC_FLAGS} -funswitch-loops")
467 if("$ENV{USER}" STREQUAL "ketmar")
468 set(K8_NATIVE_ARCH "-march=nehalem")
469 set(K8_NATIVE_TUNE "-mtune=nehalem")
471 set(K8_NATIVE_ARCH "-march=native")
472 set(K8_NATIVE_TUNE "-mtune=native")
477 message(STATUS "BUILD: using FPU")
478 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mfpmath=387")
479 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -ffloat-store")
480 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -fsignaling-nans")
481 add_definitions(-DUSE_FPU_MATH=1)
483 message(STATUS "BUILD: using AVX2/native instriction set")
484 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} ${K8_NATIVE_ARCH}")
485 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} ${K8_NATIVE_TUNE}")
486 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mavx2")
487 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mfpmath=sse")
489 message(STATUS "BUILD: using SSE4.2/native instriction set")
490 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} ${K8_NATIVE_ARCH}")
491 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} ${K8_NATIVE_TUNE}")
492 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -msse4.2")
493 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mno-avx")
494 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mfpmath=sse")
496 message(STATUS "BUILD: using SSE4.1/native instriction set")
497 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} ${K8_NATIVE_ARCH}")
498 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} ${K8_NATIVE_TUNE}")
499 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -msse4.1")
500 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mno-avx")
501 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mfpmath=sse")
503 message(STATUS "BUILD: using SSE4/native instriction set")
504 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} ${K8_NATIVE_ARCH}")
505 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} ${K8_NATIVE_TUNE}")
506 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -msse4")
507 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mno-avx")
508 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mfpmath=sse")
510 message(STATUS "BUILD: using SSE3/native instriction set")
511 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} ${K8_NATIVE_ARCH}")
512 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} ${K8_NATIVE_TUNE}")
513 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -msse3")
514 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mno-avx")
515 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mfpmath=sse")
517 message(STATUS "BUILD: using SSE2/native instriction set")
518 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} ${K8_NATIVE_ARCH}")
519 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} ${K8_NATIVE_TUNE}")
520 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -msse2")
521 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mno-avx")
522 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mfpmath=sse")
526 message(STATUS "***BUILD***: using SSE2/p4 instriction set")
527 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -march=pentium4")
528 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mtune=pentium4")
529 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -msse2")
531 message(STATUS "***BUILD***: using SSE4/native instriction set")
532 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} ${K8_NATIVE_ARCH}")
533 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} ${K8_NATIVE_TUNE}")
534 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -msse4")
538 message(STATUS "***BUILD***: using SSE2/p4 instriction set")
539 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -march=pentium4")
540 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mtune=pentium4")
541 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -msse2")
543 ## ##message(STATUS "***BUILD***: using SSE4/nehalem instriction set")
544 ## ##set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -march=nehalem")
545 ## ##set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mtune=nehalem")
546 ## ##set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -msse4")
547 message(STATUS "***BUILD***: using SSE2/core2 instriction set")
548 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -march=core2")
549 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mtune=core2")
550 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -msse3")
551 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mno-sse4")
554 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mno-avx")
555 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -mfpmath=sse")
561 set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -pthread")
562 set(CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE} -pthread")
563 set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -pthread")
564 endif(NOT NO_PTHREAD)
566 set(CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE} -mwindows")
567 set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -mwindows")
572 #if(ENABLE_SIGNAL_HANDLER)
573 # set(UNFUCK_GCC_FLAGS "${UNFUCK_GCC_FLAGS} -Wno-frame-address")
574 #endif(ENABLE_SIGNAL_HANDLER)
577 if(UNSTABLE_OPTIMISATIONS)
579 message(STATUS "USING UNSTABLE GCC CODE DEGRADIZER OPTIONS!")
580 else(UNSTABLE_OPTIMISATIONS)
582 endif(UNSTABLE_OPTIMISATIONS)
585 ############################
586 ## unfuck all build types ##
587 ############################
588 string(REGEX REPLACE "-O[0-9]" " " CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
589 string(REGEX REPLACE "-O[0-9]" " " CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
591 set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -g ${UNFUCK_GCC_FLAGS}")
592 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g ${UNFUCK_GCC_FLAGS} ${UNFUCK_GXX_FLAGS}")
594 string(REGEX REPLACE "-O[0-9]" " " CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
595 string(REGEX REPLACE "-O[0-9]" " " CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
597 set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${VV_OPTIM} ${UNFUCK_GCC_FLAGS} ${K8_OPT_GCC_FLAGS}")
598 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${VV_OPTIM} ${UNFUCK_GCC_FLAGS} ${UNFUCK_GXX_FLAGS} ${K8_OPT_GCC_FLAGS}")
600 string(REGEX REPLACE "-O[0-9]" " " CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
601 string(REGEX REPLACE "-O[0-9]" " " CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
603 set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} ${VV_OPTIM} -g ${UNFUCK_GCC_FLAGS} ${K8_OPT_GCC_FLAGS}")
604 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${VV_OPTIM} -g ${UNFUCK_GCC_FLAGS} ${UNFUCK_GXX_FLAGS} ${K8_OPT_GCC_FLAGS}")
606 string(REGEX REPLACE "-O[0-9]" " " CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}")
607 string(REGEX REPLACE "-O[0-9]" " " CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}")
609 set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_RELWITHDEBINFO} -Os ${UNFUCK_GCC_FLAGS}")
610 set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -Os ${UNFUCK_GCC_FLAGS} ${UNFUCK_GXX_FLAGS}")
613 add_definitions(-DZDBSP_DISABLE_SSE=1)
615 if(NOT WITH_MIMALLOC)
616 add_definitions(-DVAVOOM_DISABLE_MIMALLOC)
617 message(STATUS "Using system memory allocator")
618 endif(NOT WITH_MIMALLOC)
620 set(VAVOOM_MAIN_DEPS "")
623 set(WINERUN "$ENV{K8VAVOOM_WINE}")
632 ## message(STATUS "BUILD: ${CMAKE_BUILD_TYPE}")
633 ## message(STATUS "cflags : ${CMAKE_C_FLAGS}")
634 ## message(STATUS "cxxflags: ${CMAKE_CXX_FLAGS}")
635 ## message(STATUS "cflags (dbg): ${CMAKE_C_FLAGS_DEBUG}")
636 ## message(STATUS "cxxflags(dbg): ${CMAKE_CXX_FLAGS_DEBUG}")
638 if(NOT DEFINED DATADIR)
639 set(DATADIR share/k8vavoom)
640 endif(NOT DEFINED DATADIR)
641 if(NOT DEFINED BINDIR)
643 endif(NOT DEFINED BINDIR)
644 if(NOT DEFINED SPECSDIR)
646 endif(NOT DEFINED SPECSDIR)
650 # **** Check for inttypes.h ****
652 ### find_path(INTTYPES_INCLUDE_DIR inttypes.h)
653 ### if(INTTYPES_INCLUDE_DIR)
654 ### add_definitions(-DHAVE_INTTYPES_H=1)
655 ### endif(INTTYPES_INCLUDE_DIR)
659 # **** Check for newtwork libraries ****
662 set(NET_LIBRARIES wsock32)
664 set(NET_LIBRARIES "")
669 # **** pkg-config is required ****
671 FIND_PACKAGE(PkgConfig REQUIRED)
675 # **** Check for zlib ****
680 # include_directories(${ZLIB_INCLUDE_DIR})
682 # message(STATUS "WARNING: Zlib not found, using internal zlib")
683 # set(WITH_SYS_ZLIB OFF)
684 # set(ZLIB_LIBRARIES z)
685 # set(VAVOOM_MAIN_DEPS ${VAVOOM_MAIN_DEPS} z)
688 # add_definitions(-DUSE_INTERNAL_ZLIB=1)
689 # add_definitions(-DHAVE_ZLIB_H=1)
690 # message(STATUS "Using built-in zlib")
691 # set(ZLIB_LIBRARIES "z")
692 # set(VAVOOM_MAIN_DEPS ${VAVOOM_MAIN_DEPS} z)
693 #endif(WITH_SYS_ZLIB)
694 #set(MAIN_LIBS z ${MAIN_LIBS})
698 # **** Check for libjpeg ****
700 if(ENABLE_CLIENT OR ENABLE_SERVER OR ENABLE_VCCRUN)
703 add_definitions(-DVAVOOM_DISABLE_STB_IMAGE_JPEG=1)
707 include_directories(${JPEG_INCLUDE_DIR})
708 set(MAIN_LIBS ${JPEG_LIBRARIES} ${MAIN_LIBS})
709 add_definitions(-DVAVOOM_USE_LIBJPG=1)
711 message(STATUS "WARNING: LibJpeg not found, using internal jpeg reader")
712 set(WITH_SYS_LIBJPG OFF)
714 endif(WITH_SYS_LIBJPG)
716 if(NOT WITH_SYS_LIBJPG)
717 set(MAIN_LIBS jpeg ${MAIN_LIBS})
718 set(VAVOOM_MAIN_DEPS ${VAVOOM_MAIN_DEPS} jpeg)
719 endif(NOT WITH_SYS_LIBJPG)
721 endif(ENABLE_CLIENT OR ENABLE_SERVER OR ENABLE_VCCRUN)
725 # **** Check for liblzma ****
728 # find_package(LibLZMA)
730 # include_directories(${LIBLZMA_INCLUDE_DIRS})
731 # #message(STATUS "***: " ${LIBLZMA_INCLUDE_DIRS})
732 # #message(STATUS "***: " ${LIBLZMA_LIBRARIES})
733 # set(MAIN_LIBS ${LIBLZMA_LIBRARIES} ${MAIN_LIBS})
734 # else(LIBLZMA_FOUND)
735 # message(STATUS "WARNING: LibLzma not found, using internal lzma decoder")
736 # set(WITH_SYS_LZMA OFF)
737 # endif(LIBLZMA_FOUND)
738 #endif(WITH_SYS_LZMA)
740 #if(NOT WITH_SYS_LZMA)
741 # set(MAIN_LIBS lzma ${MAIN_LIBS})
742 # set(VAVOOM_MAIN_DEPS ${VAVOOM_MAIN_DEPS} lzma)
743 # add_definitions(-DUSE_INTERNAL_LZMA=1)
744 #endif(NOT WITH_SYS_LZMA)
746 #if(NOT WITH_SYS_LZMA)
747 # message(STATUS "LZMA: using internal liblzma")
748 # set(LIBLZMA_LIBRARIES "lzma")
749 # add_definitions(-DUSE_INTERNAL_LZMA=1)
750 #endif(NOT WITH_SYS_LZMA)
754 # **** Check for OpenAL ****
756 if(ENABLE_CLIENT OR ENABLE_VCCRUN)
759 message(FATAL_ERROR "WITH_SDL2 required for MojoAL")
761 #check_include_file(SDL2/SDL_mixer.h HAVE_SDL2_SUBDIR)
762 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lSDL2_mixer")
763 add_definitions(-DVAVOOM_USE_MOJOAL=1)
765 find_package(OpenAL REQUIRED)
766 include_directories(${OPENAL_INCLUDE_DIR})
767 if(WITH_STATIC_OPENAL)
768 #k8: my MXE builds are static. live with it.
769 add_definitions(-DAL_LIBTYPE_STATIC=1)
770 endif(WITH_STATIC_OPENAL)
771 set(MAIN_LIBS ${OPENAL_LIBRARY} ${MAIN_LIBS})
773 set(MAIN_LIBS ${OPENAL_LIBRARY} winmm ${MAIN_LIBS})
776 endif(ENABLE_CLIENT OR ENABLE_VCCRUN)
779 set(VAVOOM_SHITDOZE_LIBS winmm setupapi samplerate)
781 set(VAVOOM_SHITDOZE_LIBS )
784 set(MAIN_LIBS ${VAVOOM_SHITDOZE_LIBS} ${MAIN_LIBS})
786 set(NEED_SYS_OGG OFF)
789 endif(WITH_SYS_VORBIS)
796 # **** Check for libogg ****
799 PKG_CHECK_MODULES(OGG ogg)
801 message(STATUS "Found libogg: ${OGG_LIBRARIES}")
802 include_directories(${OGG_INCLUDE_DIRS})
803 set(MAIN_LIBS ${OGG_LIBRARIES} ${MAIN_LIBS})
809 # **** Check for Vorbis ****
812 PKG_CHECK_MODULES(VORBIS vorbis)
813 if(OGG_FOUND AND VORBIS_FOUND)
814 message(STATUS "Found Vorbis: ${VORBIS_LIBRARIES}")
816 include_directories(${VORBIS_INCLUDE_DIRS})
817 set(MAIN_LIBS ${VORBIS_LIBRARIES} ${MAIN_LIBS})
818 else(OGG_FOUND AND VORBIS_FOUND)
819 message(STATUS "Could NOT find OggVorbis libraries")
820 set(VORBIS_FOUND OFF)
821 message(FATAL_ERROR "You need libvorbis to compile k8vavoom.")
823 endif(OGG_FOUND AND VORBIS_FOUND)
824 else(WITH_SYS_VORBIS)
825 set(VORBIS_FOUND OFF)
826 message(STATUS "using stb_vorbis for Ogg/Vorbis decoding")
827 endif(WITH_SYS_VORBIS)
831 # **** Check for Opus ****
833 set(OPUS_USE_INTERNAL OFF)
835 PKG_CHECK_MODULES(OPUS opusfile opus)
836 if(OPUS_FOUND AND OGG_FOUND)
837 message(STATUS "Found Opus: ${OPUS_LIBRARIES}")
839 include_directories(${OPUS_INCLUDE_DIRS})
840 set(MAIN_LIBS ${OPUS_LIBRARIES} ${MAIN_LIBS})
841 else(OPUS_FOUND AND OGG_FOUND)
842 message(STATUS "Could NOT find Opus libraries")
844 message(FATAL_ERROR "You need libopus to compile k8vavoom.")
846 endif(OPUS_FOUND AND OGG_FOUND)
849 set(OPUS_USE_INTERNAL ON)
850 include_directories(${CMAKE_SOURCE_DIR}/libs/opus/libopus/include)
851 include_directories(${CMAKE_SOURCE_DIR}/libs/opus/libopusfile/include)
853 set(MAIN_LIBS opusfile opus ${MAIN_LIBS})
854 message(STATUS "using built-in libopus and system libogg")
856 # use built-in libogg
857 include_directories(${CMAKE_SOURCE_DIR}/libs/opus/libogg/include)
858 set(MAIN_LIBS opusfile opus ogg ${MAIN_LIBS})
859 add_definitions(-DVV_BUILTIN_OGG)
860 message(STATUS "using built-in libopus and libogg")
862 add_definitions(-DVV_BUILTIN_OPUS)
868 if(ENABLE_CLIENT OR ENABLE_VCCRUN_ONLY OR ENABLE_VCCRUN)
869 set(XMPLITE_FOUND ON)
870 set(MAIN_LIBS xmplite ${MAIN_LIBS})
871 include_directories(libs/xmplite)
872 add_definitions(-DLIBXMP_CORE_PLAYER)
873 add_definitions(-DXMP_SYM_VISIBILITY)
874 endif(ENABLE_CLIENT OR ENABLE_VCCRUN_ONLY OR ENABLE_VCCRUN)
878 # **** Check for libmad ****
881 find_path(MAD_INCLUDE_DIRS mad.h)
882 find_library(MAD_LIBRARIES NAMES mad)
884 message(STATUS "Found LibMAD: ${MAD_LIBRARIES}")
886 include_directories(${MAD_INCLUDE_DIRS})
887 set(MAIN_LIBS ${MAD_LIBRARIES} ${MAIN_LIBS})
889 message(STATUS "Could NOT find LibMAD libraries")
890 set(LIBMAD_FOUND OFF)
893 set(LIBMAD_FOUND OFF)
894 message(STATUS "using dr_mp3 for MP3 decoding")
899 # **** Check for FLAC ****
902 PKG_CHECK_MODULES(FLAC flac)
904 message(STATUS "Found FLAC: ${FLAC_LIBRARIES}")
905 include_directories(${FLAC_INCLUDE_DIRS})
906 set(MAIN_LIBS ${FLAC_LIBRARIES} ${MAIN_LIBS})
908 message(STATUS "Could NOT find FLAC library")
913 message(STATUS "using dr_flac for FLAC decoding")
918 # **** Check for LibJIT ****
921 PKG_CHECK_MODULES(LIBJIT libjit)
923 message(STATUS "Found LibJIT: ${LIBJIT_LIBRARIES}")
924 include_directories(${LIBJIT_INCLUDE_DIRS})
925 set(MAIN_LIBS ${LIBJIT_LIBRARIES} ${MAIN_LIBS})
927 message(STATUS "Could not find LibJIT library (this is OK)")
928 set(LIBJIT_FOUND OFF)
931 set(LIBJIT_FOUND OFF)
932 #message(STATUS "LibJIT disabled by user")
936 add_definitions(-DUSE_LIBJIT)
941 # **** Check for FluidSynth ****
943 if(WITH_FLUID AND ENABLE_CLIENT)
945 PKG_CHECK_MODULES(FLUID fluidsynth)
946 #message(STATUS, "FINC:" ${FLUID_INCLUDE_DIRS})
947 #message(STATUS, "FLIB:" ${FLUID_LIBRARIES})
948 if(WIN32 AND FLUID_FOUND)
949 PKG_CHECK_MODULES(GLIB glib-2.0)
951 include_directories(${GLIB_INCLUDE_DIRS})
952 set(MAIN_LIBS ${GLIB_LIBRARIES} ${MAIN_LIBS})
956 endif(WIN32 AND FLUID_FOUND)
958 message(STATUS "Found FluidSynth: ${FLUID_LIBRARIES}")
960 include_directories(${FLUID_INCLUDE_DIRS})
961 set(MAIN_LIBS ${FLUID_LIBRARIES} ${MAIN_LIBS})
962 else(FLUID_INCLUDE_DIRS AND FLUID_LIBRARIES)
963 message(STATUS "Could NOT find FluidSynth libraries")
965 message(STATUS "Using built-in FluidSynth")
966 set(WITH_SYS_FLUID OFF)
971 message(STATUS "Using built-in FluidSynth")
973 endif(WITH_SYS_FLUID)
976 endif(WITH_FLUID AND ENABLE_CLIENT)
978 if(FLUID_FOUND AND NOT WITH_SYS_FLUID AND ENABLE_CLIENT)
979 add_definitions(-DBUILTIN_FLUID)
980 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libs/fluidsynth_lite/include)
981 include_directories(${CMAKE_CURRENT_BINARY_DIR}/libs/fluidsynth_lite/include)
982 set(MAIN_LIBS libfluidsynth_lite ${MAIN_LIBS})
983 endif(FLUID_FOUND AND NOT WITH_SYS_FLUID AND ENABLE_CLIENT)
987 # **** Platform specific library checks ****
990 # ---------------- Other *NIX platforms ----------------
992 if(CMAKE_CROSSCOMPILING AND ANDROID)
993 if(SDL2_INCLUDE_DIRS STREQUAL "")
994 message(FATAL_ERROR "SDL2_INCLUDE_DIRS not specified")
996 if(SDL2_LIBRARIES STREQUAL "")
997 message(FATAL_ERROR "SDL2_LIBRARIES not specified")
1001 find_package(SDL2 REQUIRED)
1002 #PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2)
1004 include_directories(${SDL2_INCLUDE_DIRS})
1005 set(MAIN_LIBS ${SDL2_LIBRARIES} ${MAIN_LIBS})
1006 #message(STATUS "SDL2 INCLUDES:" ${SDL2_INCLUDE_DIRS})
1007 #message(STATUS "SDL2 LIBS:" ${SDL2_LIBRARIES})
1009 set(OPENGL_FOUND OFF)
1010 set(WITH_OPENGL OFF)
1015 message(SEND_ERROR "SDL2 required for OpenGL")
1017 endif(NOT WITH_SDL2)
1018 set(OpenGL_GL_PREFERENCE LEGACY)
1020 # massive fucking hack because nothing works right
1021 set(OPENGL_gl_LIBRARY "-L$ENV{PORTLIBS_PREFIX}/lib -lEGL -lglapi -ldrm_nouveau")
1022 set(OPENGL_INCLUDE_DIR "$ENV{PORTLIBS_PREFIX}/include")
1023 set(OPENGL_FOUND ON)
1025 set(OPENGL_gl_LIBRARY "-L${GL4ES_LIBRARY_DIR} -lGL")
1026 set(OPENGL_INCLUDE_DIR "${GL4ES_INCLUDE_DIR}")
1027 set(OPENGL_FOUND ON)
1029 find_package(OpenGL REQUIRED)
1032 message(STATUS "Found OpenGL")
1033 include_directories(${OPENGL_INCLUDE_DIR})
1034 if(NSWITCH OR WITH_GL4ES)
1035 # have to reorder this shit or else it doesn't link
1036 set(MAIN_LIBS ${MAIN_LIBS} ${OPENGL_gl_LIBRARY})
1038 set(MAIN_LIBS ${OPENGL_gl_LIBRARY} ${MAIN_LIBS})
1042 set(OPENGL_FOUND OFF)
1048 add_definitions(-DGL4ES_HACKS)
1051 add_definitions(-DGL4ES_NO_CONSTRUCTOR)
1056 add_definitions(-UDEBUG)
1057 set(MAIN_LIBS log android ${MAIN_LIBS})
1061 add_definitions(-DUSE_GLAD=1)
1062 if(GLAD_INCLUDE_DIR AND GLAD_LIBRARY)
1063 include_directories(${GLAD_INCLUDE_DIR})
1064 set(MAIN_LIBS ${GLAD_LIBRARY} ${MAIN_LIBS})
1065 else(GLAD_INCLUDE_DIR AND GLAD_LIBRARY)
1066 include_directories("libs/glad")
1067 set(MAIN_LIBS glad ${MAIN_LIBS})
1068 set(VAVOOM_MAIN_DEPS ${VAVOOM_MAIN_DEPS} glad)
1069 endif(GLAD_INCLUDE_DIR AND GLAD_LIBRARY)
1077 message(STATUS "Building for Switch")
1078 include_directories("$ENV{DEVKITPRO}/libnx/include")
1079 include_directories("$ENV{PORTLIBS_PREFIX}/include")
1080 add_definitions(-D__SWITCH__)
1081 # add libnx at the end of lib list
1082 set(MAIN_LIBS ${MAIN_LIBS} "-L$ENV{PORTLIBS_PREFIX}/lib -lnx")
1083 message(STATUS "Libs: ${MAIN_LIBS}")
1084 # why the fuck does this not work properly in the toolchain file
1085 set(CMAKE_C_COMPILER "aarch64-none-elf-gcc")
1086 set(CMAKE_CXX_COMPILER "aarch64-none-elf-g++")
1087 set(CMAKE_AR "aarch64-none-elf-gcc-ar")
1088 set(CMAKE_RANLIB "aarch64-none-elf-gcc-ranlib")
1089 # enable necessary switches
1096 set(WITH_MIMALLOC OFF)
1097 # turn on nxlink if necessary
1099 add_definitions(-DSWITCH_NXLINK=1)
1104 # # find_package(GnuTLS)
1105 # # if(GNUTLS_FOUND)
1106 # # include_directories(${GNUTLS_INCLUDE_DIR})
1107 # # set(MAIN_LIBS ${GNUTLS_LIBRARIES} ${MAIN_LIBS})
1108 # # add_definitions(${GNUTLS_DEFINITIONS})
1109 # # add_definitions(-DUSE_GNU_TLS)
1110 # # endif(GNUTLS_FOUND)
1113 PKG_CHECK_MODULES(GNUTLS gnutls)
1115 #message(STATUS "GnuTLS INC: " ${GNUTLS_INCLUDE_DIR})
1116 #message(STATUS "GnuTLS LIB: " ${GNUTLS_LIBRARIES})
1117 #message(STATUS "GnuTLS DEF: " ${GNUTLS_DEFINITIONS})
1118 include_directories(${GNUTLS_INCLUDE_DIR})
1119 set(MAIN_LIBS ${GNUTLS_LIBRARIES} ${MAIN_LIBS})
1120 add_definitions(${GNUTLS_DEFINITIONS})
1121 add_definitions(-DUSE_GNU_TLS)
1123 endif(ENABLE_VCCRUN)
1131 PKG_CHECK_MODULES(XRANDR xrandr)
1132 PKG_CHECK_MODULES(X11 x11)
1133 if(XRANDR_FOUND AND X11_FOUND)
1134 message(STATUS "Found XRandR: ${XRANDR_LIBRARIES}")
1135 include_directories(${XRANDR_INCLUDE_DIRS})
1136 include_directories(${X11_INCLUDE_DIRS})
1137 set(MAIN_LIBS ${X11_LIBRARIES} ${XRANDR_LIBRARIES} ${MAIN_LIBS})
1138 add_definitions(-DUSE_XRANDR=1)
1139 else(XRANDR_FOUND AND X11_FOUND)
1140 message(STATUS "Could NOT find XRandR")
1141 endif(XRANDR_FOUND AND X11_FOUND)
1142 #add_definitions(-DUSE_XRANDR=1)
1143 #set(MAIN_LIBS xrandr X11 Xrandr ${MAIN_LIBS})
1148 add_definitions(-DNO_SSE=1)
1152 add_definitions(-DNO_PTHREAD=1)
1156 add_definitions(-DNO_SINCOS=1)
1160 add_definitions(-DNO_SIGNALS=1)
1164 add_definitions(-DNO_SYSCONF=1)
1168 add_definitions(-DNO_MEMRCHR=1)
1172 add_definitions(-DNO_RAWTTY=1)
1175 ### if(CMAKE_EXECUTABLE_FORMAT STREQUAL "ELF")
1176 ### add_subdirectory(libs/libbacktrace)
1177 ### #include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libbacktrace)
1178 ### set(MAIN_LIBS backtrace ${MAIN_LIBS})
1179 ### add_definitions(-DHAVE_BACKTRACE=1)
1183 message(STATUS "=== BUILD OPTIONS ===")
1184 message(STATUS "BUILD: ${CMAKE_BUILD_TYPE}")
1186 message(STATUS "WINE COMMAND: " ${WINERUN})
1188 #message(STATUS "cflags : ${CMAKE_C_FLAGS}")
1189 #message(STATUS "cxxflags: ${CMAKE_CXX_FLAGS}")
1191 message(STATUS "=== COMPONENTS ===")
1192 message(STATUS " Vavoom Client: " ${ENABLE_CLIENT})
1193 message(STATUS " Vavoom Server: " ${ENABLE_SERVER})
1194 message(STATUS " Vavoom Master: " ${ENABLE_MASTER})
1195 message(STATUS " Vavoom Query : " ${ENABLE_QUERY_DEMO})
1196 message(STATUS " VccRun : " ${ENABLE_VCCRUN})
1197 message(STATUS " strtodEx : " ${WITH_STRTODEX})
1200 message(STATUS " GNUTLS : ON")
1202 endif(ENABLE_VCCRUN)
1204 message(STATUS "SDL2 override mode")
1206 if(NOT HAVE_SDL2_SUBDIR)
1207 message(STATUS "SDL2 non-subdir mode")
1208 endif(NOT HAVE_SDL2_SUBDIR)
1209 endif(SDL2_OVERRIDE)
1212 add_subdirectory(libs)
1214 if(ENABLE_UTILS_ONLY)
1215 add_subdirectory(utils)
1216 elseif(NOT ENABLE_VCCRUN_ONLY)
1217 if(NOT CMAKE_CROSSCOMPILING OR WIN32)
1218 add_subdirectory(utils)
1219 endif(NOT CMAKE_CROSSCOMPILING OR WIN32)
1220 add_subdirectory(source)
1221 if(NOT CMAKE_CROSSCOMPILING OR WIN32)
1222 #add_subdirectory(progs)
1223 add_subdirectory(basev)
1224 endif(NOT CMAKE_CROSSCOMPILING OR WIN32)
1225 #foreach(DIR ${EXTRA_SUBDIRS})
1226 # add_subdirectory(${DIR})
1231 add_subdirectory(vccrun)
1232 endif(ENABLE_VCCRUN)