|
1 | | -cmake_minimum_required(VERSION 3.20) |
2 | | -project(server C CXX) |
3 | | - |
4 | | -# https://cmake.org/cmake/help/latest/policy/CMP0069.html |
5 | | -cmake_policy(SET CMP0069 NEW) |
6 | | -set(CMAKE_POLICY_DEFAULT_CMP0069 NEW) |
7 | | - |
8 | | -set(CMAKE_CXX_STANDARD 20) |
9 | | -set(CMAKE_CXX_STANDARD_REQUIRED ON) |
10 | | -set(CMAKE_CXX_EXTENSIONS OFF) |
11 | | -set(LINKER_LANGUAGE CXX) |
12 | | -set(USE_FOLDERS ON) |
13 | | - |
14 | | -# Generate compile_commands.json to make it easier to work with clang based tools |
15 | | -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) |
16 | | - |
| 1 | +# Initial entry point for CMake. This file sets up the `cmake/` directory, |
| 2 | +# and then forwards you to `cmake/ProjectSettings.cmake` for further configuration. |
| 3 | +# |
| 4 | +# If you're developing locally, you should build as Debug so you get the best |
| 5 | +# debugging experience. |
| 6 | +# |
| 7 | +# If you're running for performance (like for a live server) your best best is probably |
| 8 | +# to build as RelWithDebInfo so you get optimizations, but also debug symbols. |
| 9 | +# |
| 10 | +# Windows: |
| 11 | +# Ideally you'll use Ninja as your generator with -G Ninja, but if you leave it blank your system |
| 12 | +# will pick one for you. |
| 13 | +# |
| 14 | +# Quickstart: |
| 15 | +# |
| 16 | +# cmake -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo |
| 17 | +# cmake --build build --config RelWithDebInfo --parallel |
| 18 | +# |
| 19 | +# Preferred: |
| 20 | +# |
| 21 | +# Start x64 developer prompt: |
| 22 | +# "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 |
| 23 | +# |
| 24 | +# Debug configure and build: |
| 25 | +# cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug |
| 26 | +# cmake --build build --config Debug --parallel |
| 27 | +# |
| 28 | +# RelWithDebInfo configure and build: |
| 29 | +# cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo |
| 30 | +# cmake --build build --config RelWithDebInfo --parallel |
| 31 | +# |
| 32 | +# Linux: |
| 33 | +# TODO |
| 34 | +# |
| 35 | +# MacOS: |
| 36 | +# As with Linux |
| 37 | +# |
| 38 | + |
| 39 | +cmake_minimum_required(VERSION 3.28) |
| 40 | + |
| 41 | +# Set CMake policies BEFORE project() |
17 | 42 | set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) |
18 | | -include(Cache) |
19 | | -include(CPM) |
20 | | -include(Platform) |
21 | | -include(StandardProjectSettings) |
22 | | -include(CompilerWarnings) |
23 | | -include(Sanitizers) |
24 | | -include(Valgrind) |
25 | | -include(Git) |
26 | | - |
27 | | -message(STATUS "CMAKE_VERSION: ${CMAKE_VERSION}") |
28 | | -message(STATUS "CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}") |
29 | | -message(STATUS "CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}") |
30 | | -message(STATUS "CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID}") |
31 | | -message(STATUS "CMAKE_CXX_COMPILER_VERSION: ${CMAKE_CXX_COMPILER_VERSION}") |
32 | | -message(STATUS "CMAKE_CXX_STANDARD: ${CMAKE_CXX_STANDARD}") |
33 | | -message(STATUS "CMAKE_GENERATOR: ${CMAKE_GENERATOR}") |
34 | | -message(STATUS "CMAKE_GENERATOR_PLATFORM: ${CMAKE_GENERATOR_PLATFORM}") |
35 | | -message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") |
36 | | -string(TOUPPER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_UPPER) |
37 | | -message(STATUS "CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}") |
38 | | -message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}") |
39 | | -if ("${CMAKE_BUILD_TYPE_UPPER}" STREQUAL "DEBUG") |
40 | | - message(STATUS "CMAKE_CXX_FLAGS_DEBUG: ${CMAKE_CXX_FLAGS_DEBUG}") |
41 | | -elseif ("${CMAKE_BUILD_TYPE_UPPER}" STREQUAL "MINSIZEREL") |
42 | | - message(STATUS "CMAKE_CXX_FLAGS_MINSIZEREL: ${CMAKE_CXX_FLAGS_MINSIZEREL}") |
43 | | -elseif ("${CMAKE_BUILD_TYPE_UPPER}" STREQUAL "RELEASE") |
44 | | - message(STATUS "CMAKE_CXX_FLAGS_RELEASE: ${CMAKE_CXX_FLAGS_RELEASE}") |
45 | | -elseif ("${CMAKE_BUILD_TYPE_UPPER}" STREQUAL "RELWITHDEBINFO") |
46 | | - message(STATUS "CMAKE_CXX_FLAGS_RELWITHDEBINFO: ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") |
47 | | -else() |
48 | | - message(FATAL_ERROR "Did not recognise CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} to print out compiler flags.") |
49 | | -endif() |
50 | | -message(STATUS "CMAKE_EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}") |
51 | | - |
52 | | -# set(CMAKE_VERBOSE_MAKEFILE ON) |
53 | | -set(CMAKE_POSITION_INDEPENDENT_CODE ON) |
54 | | - |
55 | | -# Find Threads (pthread) |
56 | | -set(THREADS_PREFER_PTHREAD_FLAG ON) |
57 | | -find_package(Threads REQUIRED) |
58 | | -link_libraries(${CMAKE_THREAD_LIBS_INIT}) |
59 | | - |
60 | | -# Find Python (defines ${Python_EXECUTABLE}) |
61 | | -find_package(Python REQUIRED) |
62 | | -message(STATUS "Python_EXECUTABLE: ${Python_EXECUTABLE}") |
63 | | -message(STATUS "Python_VERSION: ${Python_VERSION}") |
64 | | -if(NOT ${Python_VERSION_MAJOR} EQUAL 3) |
65 | | - message(FATAL_ERROR "Python 3 is required") |
66 | | -endif() |
67 | | - |
68 | | -# Find MariaDB |
69 | | -find_package(MariaDB REQUIRED) |
70 | | -find_package(MariaDBCPP REQUIRED) |
71 | | - |
72 | | -# Find ZMQ |
73 | | -find_package(ZeroMQ REQUIRED) |
74 | | - |
75 | | -# Find LuaJIT |
76 | | -find_package(LuaJIT REQUIRED) |
77 | | - |
78 | | -# Find OpenSSL libcrypto |
79 | | -find_package(OpenSSLlibcrypto REQUIRED) |
80 | | - |
81 | | -# Find OpenSSL libssl |
82 | | -find_package(OpenSSLlibssl REQUIRED) |
83 | | - |
84 | | -if(UNIX AND NOT APPLE) |
85 | | - find_package(Binutils REQUIRED) |
86 | | -endif() |
87 | | - |
88 | | -# Link this 'library' to set the c++ standard / compile-time options requested |
89 | | -add_library(project_options INTERFACE) |
90 | | -target_compile_features(project_options INTERFACE cxx_std_17) |
91 | | - |
92 | | -# Link this 'library' to use the warnings specified in CompilerWarnings.cmake |
93 | | -add_library(project_warnings INTERFACE) |
94 | | -set_project_warnings(project_warnings) |
95 | | - |
96 | | -# Globally define SOL_ALL_SAFETIES_ON so sol can be included anywhere |
97 | | -# If SOL_NO_CHECK_NUMBER_PRECISION is defined, turns off number precision and integer |
98 | | -# precision fitting when pushing numbers into sol |
99 | | -# RC_FAST_MATH informs recastnavigation to not try to use infinity because we use -ffast-math |
100 | | -# add_compile_definitions() comes with CMake 3.12 |
101 | | -add_definitions( |
102 | | - -DSOL_ALL_SAFETIES_ON=1 |
103 | | - -DSOL_NO_CHECK_NUMBER_PRECISION=1 |
104 | | - -DSOL_DEFAULT_PASS_ON_ERROR=1 |
105 | | - -DSOL_PRINT_ERRORS=0 |
106 | | - -DRC_FAST_MATH=1 |
107 | | - -DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_DEBUG |
108 | | -) |
109 | | - |
110 | | -# For external libs |
111 | | -set(CMAKE_WARN_DEPRECATED OFF CACHE BOOL "" FORCE) |
112 | | - |
113 | | -option(PCH_ENABLE "Enable precompiled headers." ON) |
114 | | -message(STATUS "PCH_ENABLE: ${PCH_ENABLE}") |
115 | | - |
116 | | -# Tracy flags |
117 | | -option(TRACY_ENABLE "Enable Tracy profiling." OFF) |
118 | | -if(ENABLE_TRACY OR TRACY_ENABLED OR TRACY) # Also handle close flags |
119 | | - set(TRACY_ENABLE ON) |
120 | | -endif() |
121 | | -message(STATUS "TRACY_ENABLE: ${TRACY_ENABLE}") |
122 | | - |
123 | | -add_subdirectory(ext) |
124 | | - |
125 | | -include(ClangTidy) |
126 | | -include(Fuzzing) |
127 | | - |
128 | | -message(STATUS "Configuring src/common/version.cpp") |
129 | | -configure_file(${CMAKE_SOURCE_DIR}/src/common/version.cpp.in |
130 | | - ${CMAKE_SOURCE_DIR}/src/common/version.cpp) |
131 | | - |
132 | | -# Generate IPC stubs |
133 | | -set_property( |
134 | | - DIRECTORY |
135 | | - APPEND |
136 | | - PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_SOURCE_DIR}/tools/generate_ipc_stubs.py |
137 | | -) |
138 | | -message(STATUS "Generating IPC stubs") |
139 | | -message(STATUS "Calling: ${Python_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tools/generate_ipc_stubs.py ${CMAKE_BINARY_DIR}") |
140 | | -execute_process( |
141 | | - COMMAND ${Python_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tools/generate_ipc_stubs.py ${CMAKE_BINARY_DIR} |
142 | | - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} |
143 | | - RESULT_VARIABLE IPC_EXIT_CODE |
144 | | -) |
145 | | -if (NOT IPC_EXIT_CODE EQUAL 0) |
146 | | - message(FATAL_ERROR "Failed to generate IPC stubs") |
147 | | -endif() |
148 | | - |
149 | | -include_directories(${CMAKE_BINARY_DIR}/generated) # Globally include the build/generated directory |
| 43 | +include(CMakePolicies) |
150 | 44 |
|
151 | | -add_subdirectory(src) |
| 45 | +project(server C CXX) # cmake/ProjectSettings.cmake |
| 46 | +include(ProjectSettings) |
0 commit comments