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})
23 # ##############################################################################
25 option(FS1 "Build original FreeSpace" OFF)
26 option(DEMO "Create demo build" OFF)
28 if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
29 message(STATUS "Setting build type to 'Debug' as none was specified.")
30 set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
31 # Set the possible values of build type for cmake-gui
32 set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
33 "MinSizeRel" "RelWithDebInfo")
38 add_definitions(-DMAKE_FS1)
41 add_definitions(-DDEMO -DFS1_DEMO)
45 add_definitions(-DFS2_DEMO)
50 set(PLATFORM_LIBRARIES "")
52 add_definitions(-DPLAT_UNIX)
53 add_definitions(-Wall)
54 # add_definitions(-Wno-format-y2k)
55 # add_definitions(-Wno-deprecated)
56 add_definitions(-fsigned-char)
58 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DNDEBUG -g -O2")
59 set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -DNDEBUG -Os")
60 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -O2")
61 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3")
63 set(PLATFORM_LIBRARIES
68 add_definitions(/D _CRT_SECURE_NO_WARNINGS)
70 add_definitions(/wd4100) # unreferenced parameter
71 add_definitions(/wd4127) # conditional expression is constant: do { } while (0)
72 add_definitions(/wd4996) # deprecated functions: fopen, fileno, ...
76 # ##############################################################################
80 ${PROJECT_SOURCE_DIR}/include
83 ${LIBWEBSOCKETS_INCLUDE_DIR}
84 ${wxWidgets_INCLUDE_DIRS}
89 add_subdirectory(include)
92 # ##############################################################################
96 # main code/game library
113 set(FS_BINARY freespace_demo)
115 set(FS_BINARY freespace)
119 set(FS_BINARY freespace2_demo)
121 set(FS_BINARY freespace2)
125 add_executable(${FS_BINARY}
131 target_link_libraries(
137 ${LIBWEBSOCKETS_LIBRARIES}
138 ${PLATFORM_LIBRARIES}
146 set(LAUNCHER_BINARY fslaunch)
148 set(LAUNCHER_BINARY fs2launch)
151 add_executable(${LAUNCHER_BINARY}
157 target_link_libraries(
162 ${wxWidgets_LIBRARIES}
163 ${PLATFORM_LIBRARIES}
166 # wxWidgets appears to need c++11 for one or more headers
168 set_target_properties(${LAUNCHER_BINARY} PROPERTIES COMPILE_FLAGS -std=c++11)
172 # standalone server GUI
176 set(STANDALONE_BINARY fsstandalone)
178 set(STANDALONE_BINARY fs2standalone)
181 add_executable(${STANDALONE_BINARY}
184 ${standalone_HEADERS}
187 target_link_libraries(
190 ${wxWidgets_LIBRARIES}
191 ${LIBWEBSOCKETS_LIBRARIES}
192 ${PLATFORM_LIBRARIES}
195 # wxWidgets appears to need c++11 for one or more headers
197 set_target_properties(${STANDALONE_BINARY} PROPERTIES COMPILE_FLAGS -std=c++11)
201 # ##############################################################################
203 # ##############################################################################
205 # toolset: targets for creating/modifying game assets
218 target_link_libraries(
224 ${LIBWEBSOCKETS_LIBRARIES}
225 ${PLATFORM_LIBRARIES}
229 # CFILEARCHIVER: to create VP file archives
232 add_executable(cfilearchiver
234 ${cfilearchiver_SOURCE}
238 # CRYPTSTRING: string encryption (for embedded cheat codes)
241 add_executable(cryptstring
243 ${cryptstring_SOURCE}
247 # NEBEDIT: FS1 style nebula editor/creator
250 add_executable(nebedit
256 target_link_libraries(
262 ${wxWidgets_LIBRARIES}
263 ${LIBWEBSOCKETS_LIBRARIES}
264 ${PLATFORM_LIBRARIES}
267 # wxWidgets appears to need c++11 for one or more headers
269 set_target_properties(nebedit PROPERTIES COMPILE_FLAGS -std=c++11)
273 # POFVIEW: model viewer
276 add_executable(pofview
283 target_link_libraries(
289 ${wxWidgets_LIBRARIES}
290 ${LIBWEBSOCKETS_LIBRARIES}
291 ${PLATFORM_LIBRARIES}
294 # wxWidgets appears to need c++11 for one or more headers
296 set_target_properties(pofview PROPERTIES COMPILE_FLAGS -std=c++11)
300 # SCRAMBLE: file-based encryption for TBLs
303 add_executable(scramble
310 # FONTTOOL: create font files / edit kerning data
313 add_executable(fonttool
320 # background setup, to allow running from build location without installing
321 add_custom_command(TARGET fonttool
323 COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/src/fonttool"
324 COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/src/fonttool/fonttool.pcx" "${CMAKE_CURRENT_BINARY_DIR}/src/fonttool"
327 target_link_libraries(
333 ${LIBWEBSOCKETS_LIBRARIES}
334 ${PLATFORM_LIBRARIES}
338 # custom target to build all tools in one pass
341 add_custom_target(tools)
343 add_dependencies(tools
354 # ##############################################################################
357 # optionally include any dev/user preferred build commands and/or options
360 include(custom.cmake OPTIONAL)