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
70 add_definitions(/D _CRT_SECURE_NO_WARNINGS)
72 add_definitions(/wd4100) # unreferenced parameter
73 add_definitions(/wd4127) # conditional expression is constant: do { } while (0)
74 add_definitions(/wd4996) # deprecated functions: fopen, fileno, ...
78 # ##############################################################################
82 ${PROJECT_SOURCE_DIR}/include
85 ${LIBWEBSOCKETS_INCLUDE_DIR}
86 ${wxWidgets_INCLUDE_DIRS}
91 add_subdirectory(include)
94 # ##############################################################################
98 # main code/game library
109 CreateSourceGroups(${code_SOURCE} ${platform_SOURCE})
117 set(FS_BINARY freespace_demo)
119 set(FS_BINARY freespace)
123 set(FS_BINARY freespace2_demo)
125 set(FS_BINARY freespace2)
129 add_executable(${FS_BINARY}
135 CreateSourceGroups(${freespace_SOURCE})
137 target_link_libraries(
143 ${LIBWEBSOCKETS_LIBRARIES}
144 ${PLATFORM_LIBRARIES}
152 set(LAUNCHER_BINARY fslaunch)
154 set(LAUNCHER_BINARY fs2launch)
157 add_executable(${LAUNCHER_BINARY}
163 CreateSourceGroups(${launcher_SOURCE})
165 target_link_libraries(
170 ${wxWidgets_LIBRARIES}
171 ${PLATFORM_LIBRARIES}
174 # wxWidgets appears to need c++11 for one or more headers
176 set_target_properties(${LAUNCHER_BINARY} PROPERTIES COMPILE_FLAGS -std=c++11)
180 # standalone server GUI
184 set(STANDALONE_BINARY fsstandalone)
186 set(STANDALONE_BINARY fs2standalone)
189 add_executable(${STANDALONE_BINARY}
192 ${standalone_HEADERS}
195 CreateSourceGroups(${standalone_SOURCE})
197 target_link_libraries(
200 ${wxWidgets_LIBRARIES}
201 ${LIBWEBSOCKETS_LIBRARIES}
202 ${PLATFORM_LIBRARIES}
205 # wxWidgets appears to need c++11 for one or more headers
207 set_target_properties(${STANDALONE_BINARY} PROPERTIES COMPILE_FLAGS -std=c++11)
211 # ##############################################################################
213 # ##############################################################################
215 # toolset: targets for creating/modifying game assets
228 CreateSourceGroups(${ac_SOURCE})
230 target_link_libraries(
236 ${LIBWEBSOCKETS_LIBRARIES}
237 ${PLATFORM_LIBRARIES}
241 # CFILEARCHIVER: to create VP file archives
244 add_executable(cfilearchiver
246 ${cfilearchiver_SOURCE}
249 CreateSourceGroups(${cfilearchiver_SOURCE})
252 # CRYPTSTRING: string encryption (for embedded cheat codes)
255 add_executable(cryptstring
257 ${cryptstring_SOURCE}
260 CreateSourceGroups(${cryptstring_SOURCE})
263 # NEBEDIT: FS1 style nebula editor/creator
266 add_executable(nebedit
272 CreateSourceGroups(${nebedit_SOURCE})
274 target_link_libraries(
280 ${wxWidgets_LIBRARIES}
281 ${LIBWEBSOCKETS_LIBRARIES}
282 ${PLATFORM_LIBRARIES}
285 # wxWidgets appears to need c++11 for one or more headers
287 set_target_properties(nebedit PROPERTIES COMPILE_FLAGS -std=c++11)
291 # POFVIEW: model viewer
294 add_executable(pofview
301 CreateSourceGroups(${pofview_SOURCE})
303 target_link_libraries(
309 ${wxWidgets_LIBRARIES}
310 ${LIBWEBSOCKETS_LIBRARIES}
311 ${PLATFORM_LIBRARIES}
314 # wxWidgets appears to need c++11 for one or more headers
316 set_target_properties(pofview PROPERTIES COMPILE_FLAGS -std=c++11)
320 # SCRAMBLE: file-based encryption for TBLs
323 add_executable(scramble
329 CreateSourceGroups(${scramble_SOURCE})
332 # FONTTOOL: create font files / edit kerning data
335 add_executable(fonttool
342 CreateSourceGroups(${fonttool_SOURCE})
344 # background setup, to allow running from build location without installing
345 add_custom_command(TARGET fonttool
347 COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/src/fonttool"
348 COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/src/fonttool/fonttool.pcx" "${CMAKE_CURRENT_BINARY_DIR}/src/fonttool"
351 target_link_libraries(
357 ${LIBWEBSOCKETS_LIBRARIES}
358 ${PLATFORM_LIBRARIES}
362 # custom target to build all tools in one pass
365 add_custom_target(tools)
367 add_dependencies(tools
378 # ##############################################################################
381 # optionally include any dev/user preferred build commands and/or options
384 include(custom.cmake OPTIONAL)