4 cmake_minimum_required(VERSION 2.8)
5 cmake_policy(VERSION 2.8)
8 cmake_policy(SET CMP0043 OLD)
11 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
14 find_package(SDL2 "2.0.1" REQUIRED)
15 find_package(OpenGL REQUIRED)
16 find_package(OpenAL REQUIRED)
17 find_package(LibWebSockets REQUIRED)
19 find_package(wxWidgets COMPONENTS core base gl net)
20 include(${wxWidgets_USE_FILE})
22 include(CreateSourceGroups)
25 # ##############################################################################
27 option(FS1 "Build original FreeSpace" OFF)
28 option(DEMO "Create demo build" OFF)
30 if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
31 message(STATUS "Setting build type to 'Debug' as none was specified.")
32 set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
33 # Set the possible values of build type for cmake-gui
34 set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
35 "MinSizeRel" "RelWithDebInfo")
40 add_definitions(-DMAKE_FS1)
43 add_definitions(-DDEMO -DFS1_DEMO)
47 add_definitions(-DFS2_DEMO)
52 set(PLATFORM_LIBRARIES "")
54 add_definitions(-DPLAT_UNIX)
55 add_definitions(-Wall)
56 # add_definitions(-Wno-format-y2k)
57 # add_definitions(-Wno-deprecated)
58 add_definitions(-fsigned-char)
60 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DNDEBUG -g -O2")
61 set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -DNDEBUG -Os")
62 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -O2")
63 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3")
65 set(PLATFORM_LIBRARIES
69 add_definitions(/D _CRT_SECURE_NO_WARNINGS)
71 add_definitions(/wd4100) # unreferenced parameter
72 add_definitions(/wd4127) # conditional expression is constant: do { } while (0)
73 add_definitions(/wd4996) # deprecated functions: fopen, fileno, ...
77 # ##############################################################################
81 ${PROJECT_SOURCE_DIR}/include
84 ${LIBWEBSOCKETS_INCLUDE_DIR}
85 ${wxWidgets_INCLUDE_DIRS}
90 add_subdirectory(include)
93 # ##############################################################################
97 # main code/game library
108 CreateSourceGroups(${code_SOURCE} ${platform_SOURCE})
116 set(FS_BINARY freespace_demo)
118 set(FS_BINARY freespace)
122 set(FS_BINARY freespace2_demo)
124 set(FS_BINARY freespace2)
128 add_executable(${FS_BINARY}
134 CreateSourceGroups(${freespace_SOURCE})
136 target_link_libraries(
142 ${LIBWEBSOCKETS_LIBRARIES}
143 ${PLATFORM_LIBRARIES}
151 set(LAUNCHER_BINARY fslaunch)
153 set(LAUNCHER_BINARY fs2launch)
156 add_executable(${LAUNCHER_BINARY}
162 CreateSourceGroups(${launcher_SOURCE})
164 target_link_libraries(
169 ${wxWidgets_LIBRARIES}
170 ${PLATFORM_LIBRARIES}
173 # wxWidgets appears to need c++11 for one or more headers
175 set_target_properties(${LAUNCHER_BINARY} PROPERTIES COMPILE_FLAGS -std=c++11)
179 # standalone server GUI
183 set(STANDALONE_BINARY fsstandalone)
185 set(STANDALONE_BINARY fs2standalone)
188 add_executable(${STANDALONE_BINARY}
191 ${standalone_HEADERS}
194 CreateSourceGroups(${standalone_SOURCE})
196 target_link_libraries(
199 ${wxWidgets_LIBRARIES}
200 ${LIBWEBSOCKETS_LIBRARIES}
201 ${PLATFORM_LIBRARIES}
204 # wxWidgets appears to need c++11 for one or more headers
206 set_target_properties(${STANDALONE_BINARY} PROPERTIES COMPILE_FLAGS -std=c++11)
210 # ##############################################################################
212 # ##############################################################################
214 # toolset: targets for creating/modifying game assets
227 CreateSourceGroups(${ac_SOURCE})
229 target_link_libraries(
235 ${LIBWEBSOCKETS_LIBRARIES}
236 ${PLATFORM_LIBRARIES}
240 # CFILEARCHIVER: to create VP file archives
243 add_executable(cfilearchiver
245 ${cfilearchiver_SOURCE}
248 CreateSourceGroups(${cfilearchiver_SOURCE})
251 # CRYPTSTRING: string encryption (for embedded cheat codes)
254 add_executable(cryptstring
256 ${cryptstring_SOURCE}
259 CreateSourceGroups(${cryptstring_SOURCE})
262 # NEBEDIT: FS1 style nebula editor/creator
265 add_executable(nebedit
271 CreateSourceGroups(${nebedit_SOURCE})
273 target_link_libraries(
279 ${wxWidgets_LIBRARIES}
280 ${LIBWEBSOCKETS_LIBRARIES}
281 ${PLATFORM_LIBRARIES}
284 # wxWidgets appears to need c++11 for one or more headers
286 set_target_properties(nebedit PROPERTIES COMPILE_FLAGS -std=c++11)
290 # POFVIEW: model viewer
293 add_executable(pofview
300 CreateSourceGroups(${pofview_SOURCE})
302 target_link_libraries(
308 ${wxWidgets_LIBRARIES}
309 ${LIBWEBSOCKETS_LIBRARIES}
310 ${PLATFORM_LIBRARIES}
313 # wxWidgets appears to need c++11 for one or more headers
315 set_target_properties(pofview PROPERTIES COMPILE_FLAGS -std=c++11)
319 # SCRAMBLE: file-based encryption for TBLs
322 add_executable(scramble
328 CreateSourceGroups(${scramble_SOURCE})
331 # FONTTOOL: create font files / edit kerning data
334 add_executable(fonttool
341 CreateSourceGroups(${fonttool_SOURCE})
343 # background setup, to allow running from build location without installing
344 add_custom_command(TARGET fonttool
346 COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/src/fonttool"
347 COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/src/fonttool/fonttool.pcx" "${CMAKE_CURRENT_BINARY_DIR}/src/fonttool"
350 target_link_libraries(
356 ${LIBWEBSOCKETS_LIBRARIES}
357 ${PLATFORM_LIBRARIES}
361 # custom target to build all tools in one pass
364 add_custom_target(tools)
366 add_dependencies(tools
377 # ##############################################################################
380 # optionally include any dev/user preferred build commands and/or options
383 include(custom.cmake OPTIONAL)