|
| 1 | +cmake_minimum_required(VERSION 3.11) |
| 2 | +project(ioquake3 VERSION 1.36 LANGUAGES C ASM) |
| 3 | + |
| 4 | +include(CheckSymbolExists) |
| 5 | +include(CheckCCompilerFlag) |
| 6 | + |
| 7 | +set(ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) |
| 8 | +set(CODE_DIR ${ROOT_DIR}/code) |
| 9 | +set(LIBS_DIR ${ROOT_DIR}/libs) |
| 10 | + |
| 11 | +set(ENGINE_BINARY_DIR ${CMAKE_BINARY_DIR}) |
| 12 | + |
| 13 | +option(DEFAULT_BASEDIR "extra path to search for baseq3 and such" "") |
| 14 | +option(BUILD_CLIENT "build the 'ioquake3' client binary" ON) |
| 15 | +option(BUILD_SERVER "build the 'ioq3ded' server binary" ON) |
| 16 | +option(BUILD_RENDERER_OPENGL2 "" ON) |
| 17 | +option(BUILD_AUTOUPDATER "DON'T build unless you mean to!" OFF) |
| 18 | +option(BUILD_STANDALONE "build binaries suited for stand-alone games" OFF) |
| 19 | + |
| 20 | +set(SERVERBIN "ioq3ded" CACHE STRING "server binary") |
| 21 | +set(CLIENTBIN "ioquake3" CACHE STRING "client binary") |
| 22 | + |
| 23 | +option(USE_RENDERER_DLOPEN "build and use the renderer in a library" ON) |
| 24 | +option(USE_OPENAL_DLOPEN "link with OpenAL at runtime" ON) |
| 25 | +option(USE_CURL_DLOPEN "link with libcurl at runtime" ON) |
| 26 | +option(USE_VOIP "enable built-in VoIP support" ON) |
| 27 | +option(USE_MUMBLE "enable Mumble support" ON) |
| 28 | + |
| 29 | +if (MSVC) |
| 30 | + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO") |
| 31 | + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /MANIFEST:NO") |
| 32 | + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /MANIFEST:NO") |
| 33 | + # 4244 conversion from 'float' to 'int', possible loss of data |
| 34 | + # 4305 truncation from 'double' to 'float' |
| 35 | + # 4820 padding |
| 36 | + # 5045 spectre instruction |
| 37 | + # 4668 unknown macro definition |
| 38 | + # 4061 explicit switch case enum mention |
| 39 | + # 4242 possible loss of data (convert int to short) |
| 40 | + # 4464 relative include path |
| 41 | + # 4619 warning id is not available |
| 42 | + # 4245 return signed/unsigned conflict |
| 43 | + # 4100 unreferenced formal parameter |
| 44 | + # 4255 invalid function prototype - missing void |
| 45 | + # 4389 comparison signed/unsigned |
| 46 | + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4267 /wd4244 /wd4305 /wd4820 /wd5045 /wd4668 /wd4061 /wd4242 /wd4464 /wd4619 /wd4245 /wd4100 /wd4255 /wd4389") |
| 47 | + add_compile_definitions(_CRT_SECURE_NO_WARNINGS) |
| 48 | +endif() |
| 49 | + |
| 50 | +set(CMAKE_POSITION_INDEPENDENT_CODE ON) |
| 51 | + |
| 52 | +if (APPLE) |
| 53 | + set(CMAKE_OSX_DEPLOYMENT_TARGET 10.9) |
| 54 | + add_compile_definitions(MAC_OS_X_VERSION_MIN_REQUIRED=1070) |
| 55 | +endif() |
| 56 | + |
| 57 | +set(ARCH_STRING x86) |
| 58 | +if(CMAKE_SIZEOF_VOID_P EQUAL 8) |
| 59 | + set(ARCH_STRING x86_64) |
| 60 | +endif() |
| 61 | + |
| 62 | +add_compile_definitions(PRODUCT_VERSION="${CMAKE_PROJECT_VERSION}" ARCH_STRING="${ARCH_STRING}") |
| 63 | + |
| 64 | +if (BUILD_STANDALONE) |
| 65 | + add_compile_definitions(STANDALONE) |
| 66 | +endif() |
| 67 | + |
| 68 | +macro(check_compiler_flag flag) |
| 69 | + string(REGEX REPLACE "[-=+]" "_" _flag ${flag}) |
| 70 | + string(TOUPPER ${_flag} _flagfinal) |
| 71 | + check_c_compiler_flag("${flag}" COMPILER_SUPPORTS_${_flagfinal}) |
| 72 | + if (COMPILER_SUPPORTS_${_flagfinal}) |
| 73 | + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}") |
| 74 | + endif() |
| 75 | +endmacro() |
| 76 | + |
| 77 | +check_compiler_flag(-Wformat=2) |
| 78 | +check_compiler_flag(-Wno-format-zero-length) |
| 79 | +check_compiler_flag(-Wformat-security) |
| 80 | +check_compiler_flag(-Wno-format-nonliteral) |
| 81 | +check_compiler_flag(-Wstrict-aliasing=2) |
| 82 | +check_compiler_flag(-Wmissing-format-attribute) |
| 83 | +check_compiler_flag(-Wdisabled-optimization) |
| 84 | +check_compiler_flag(-Werror-implicit-function-declaration) |
| 85 | + |
| 86 | +add_subdirectory(code) |
0 commit comments