Debian Codegraph @

CMakeLists.txt

raw ◀ ▶
Source reconstructed at patch state 0 of 3 — not the installed (fully patched) source.
3 Debian patches touch this file
1 cmake_minimum_required(VERSION 3.9.0)
2
3 set(CMAKE_VERBOSE_MAKEFILE ON)
4
5 # Set project name and languge.
6 project(mvdsv C)
7
8
9 ######################################################################################################
10
11 # Checkout shared qwprot repository
12 find_package(Git QUIET)
13 if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
14 option(GIT_SUBMODULE "Check submodules during build" ON)
15 if(GIT_SUBMODULE)
16 message(STATUS "Submodule update")
17 execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
18 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
19 RESULT_VARIABLE GIT_SUBMOD_RESULT)
20 if(NOT GIT_SUBMOD_RESULT EQUAL "0")
21 message(FATAL_ERROR "git submodule update --init --recursive failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
22 endif()
23 endif()
24 endif()
25
26
27 ######################################################################################################
28
29 # Set where sources located.
30 set(DIR_SRC "src")
31
32 # Add sources
33 set(SRC_COMMON
34 "${DIR_SRC}/bothtools.c"
35 "${DIR_SRC}/build.c"
36 "${DIR_SRC}/cmd.c"
37 "${DIR_SRC}/cmodel.c"
38 "${DIR_SRC}/common.c"
39 "${DIR_SRC}/crc.c"
40 "${DIR_SRC}/cvar.c"
41 "${DIR_SRC}/fs.c"
42 "${DIR_SRC}/hash.c"
43 "${DIR_SRC}/mathlib.c"
44 "${DIR_SRC}/md4.c"
45 "${DIR_SRC}/net.c"
46 "${DIR_SRC}/net_chan.c"
47 "${DIR_SRC}/pmove.c"
48 "${DIR_SRC}/pmovetst.c"
49 "${DIR_SRC}/pr2_cmds.c"
50 "${DIR_SRC}/pr2_edict.c"
51 "${DIR_SRC}/pr2_exec.c"
52 "${DIR_SRC}/vm.c"
53 "${DIR_SRC}/vm_interpreted.c"
54 "${DIR_SRC}/vm_x86.c"
55 "${DIR_SRC}/pr_cmds.c"
56 "${DIR_SRC}/pr_edict.c"
57 "${DIR_SRC}/pr_exec.c"
58 "${DIR_SRC}/sha1.c"
59 "${DIR_SRC}/sha3.c"
60 "${DIR_SRC}/sv_ccmds.c"
61 "${DIR_SRC}/sv_demo.c"
62 "${DIR_SRC}/sv_demo_misc.c"
63 "${DIR_SRC}/sv_demo_qtv.c"
64 "${DIR_SRC}/sv_ents.c"
65 "${DIR_SRC}/sv_init.c"
66 "${DIR_SRC}/sv_login.c"
67 "${DIR_SRC}/sv_main.c"
68 "${DIR_SRC}/sv_master.c"
69 "${DIR_SRC}/sv_mod_frags.c"
70 "${DIR_SRC}/sv_move.c"
71 "${DIR_SRC}/sv_nchan.c"
72 "${DIR_SRC}/sv_phys.c"
73 "${DIR_SRC}/sv_save.c"
74 "${DIR_SRC}/sv_send.c"
75 "${DIR_SRC}/sv_user.c"
76 "${DIR_SRC}/vfs_os.c"
77 "${DIR_SRC}/vfs_pak.c"
78 "${DIR_SRC}/sv_world.c"
79 "${DIR_SRC}/zone.c"
80 )
81
82 # Check build target, and included sources
83 if(UNIX)
84 list(APPEND SRC_COMMON
85 "${DIR_SRC}/sv_sys_unix.c"
86 )
87 # Check for curl, and include sources and libs, if found
88 find_package(CURL)
89 if(NOT CURL_FOUND)
90 message(STATUS "Curl library not found")
91 else()
92 list(APPEND SRC_COMMON
93 "${DIR_SRC}/central.c"
94 )
95 endif()
96 else()
97 list(APPEND SRC_COMMON
98 "${DIR_SRC}/sv_sys_win.c"
99 "${DIR_SRC}/sv_windows.c"
100 "${DIR_SRC}/winquake.rc"
101 )
102 endif()
103
104 ######################################################################################################
105
106 # Check for PCRE. if found, include it; if not found, use bundled PCRE.
107 find_library(PCRE_LIBRARIES pcre2-8)
108 if(PCRE_LIBRARIES)
109 set(PCRE_FOUND 1)
110 find_path(PCRE_INCLUDE_DIR pcre2.h)
111 endif(PCRE_LIBRARIES)
112
113 if(NOT PCRE_FOUND)
114 message(FATAL_ERROR "PCRE library not found.")
115 else()
116 message(STATUS "Found PCRE: ${PCRE_LIBRARIES}")
117 endif()
118
119 ######################################################################################################
120
121 # Set base compiler flags
122 set(CFLAGS -Wall -std=gnu17)
123 set(LFLAGS)
124
125
126 ######################################################################################################
127 # Mark the executable as a non-console application
128 if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
129 set(TARGET_TYPE WIN32)
130 endif()
131 add_executable(${PROJECT_NAME} ${TARGET_TYPE} ${SRC_COMMON})
132 set_target_properties(${PROJECT_NAME}
133 PROPERTIES #PREFIX "" # Strip lib prefix.
134 C_VISIBILITY_PRESET hidden # Hide all symbols unless excplicitly marked to export.
135 )
136
137
138 ######################################################################################################
139
140 # Set include directories
141 target_include_directories(${PROJECT_NAME} PRIVATE ${DIR_SRC}/qwprot/src)
142 target_include_directories(${PROJECT_NAME} PRIVATE ${CURL_INCLUDE_DIRS})
143 target_include_directories(${PROJECT_NAME} PRIVATE ${PCRE_INCLUDE_DIR})
144 target_include_directories(${PROJECT_NAME} PRIVATE "/usr/include/qwprot/")
145
146
147 ######################################################################################################
148
149 # Check build target, and included sources and libs
150 if(UNIX)
151 target_link_libraries(${PROJECT_NAME} m)
152 target_link_libraries(${PROJECT_NAME} ${CMAKE_DL_LIBS})
153 else()
154 target_link_libraries(${PROJECT_NAME} ws2_32)
155 target_link_libraries(${PROJECT_NAME} winmm)
156 if(NOT CMAKE_C_COMPILER_ID STREQUAL "MSVC")
157 set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc")
158 endif()
159 endif()
160
161
162 ######################################################################################################
163
164 # Set defines for the build
165 target_compile_definitions(${PROJECT_NAME} PRIVATE SERVERONLY)
166 target_compile_definitions(${PROJECT_NAME} PRIVATE USE_PR2)
167 target_compile_definitions(${PROJECT_NAME} PRIVATE MVD_PEXT1_SERVERSIDEWEAPON)
168 target_compile_definitions(${PROJECT_NAME} PRIVATE MVD_PEXT1_SERVERSIDEWEAPON2)
169 target_compile_definitions(${PROJECT_NAME} PRIVATE FTE_PEXT2_VOICECHAT)
170
171 include (TestBigEndian)
172 TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
173 if(IS_BIG_ENDIAN)
174 target_compile_definitions(${PROJECT_NAME} PRIVATE __BIG_ENDIAN__Q__)
175 message(STATUS "BIG_ENDIAN")
176 else()
177 target_compile_definitions(${PROJECT_NAME} PRIVATE __LITTLE_ENDIAN__Q__)
178 message(STATUS "LITTLE_ENDIAN")
179 endif()
180
181 if(CURL_FOUND)
182 target_compile_definitions(${PROJECT_NAME} PRIVATE WWW_INTEGRATION)
183 target_link_libraries(${PROJECT_NAME} ${CURL_LIBRARIES})
184 endif()
185
186 if(PCRE_FOUND)
187 target_link_libraries(${PROJECT_NAME} ${PCRE_LIBRARIES})
188 endif()
189
190
191 ######################################################################################################
192
193 # Assign compiler flags
194 target_compile_options(${PROJECT_NAME} PRIVATE ${CFLAGS})
195
196 if(NOT CMAKE_C_COMPILER_ID STREQUAL "MSVC")
197 target_link_libraries(${PROJECT_NAME} -lpthread)
198 endif()
199
200
201 ######################################################################################################