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)
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 # ##############################################################################
174 # ##############################################################################
176 # toolset: targets for creating/modifying game assets
189 target_link_libraries(
195 ${PLATFORM_LIBRARIES}
199 # CFILEARCHIVER: to create VP file archives
202 add_executable(cfilearchiver
204 ${cfilearchiver_SOURCE}
208 # CRYPTSTRING: string encryption (for embedded cheat codes)
211 add_executable(cryptstring
213 ${cryptstring_SOURCE}
217 # NEBEDIT: FS1 style nebula editor/creator
220 add_executable(nebedit
226 target_link_libraries(
232 ${wxWidgets_LIBRARIES}
233 ${PLATFORM_LIBRARIES}
236 # wxWidgets appears to need c++11 for one or more headers
238 set_target_properties(nebedit PROPERTIES COMPILE_FLAGS -std=c++11)
242 # POFVIEW: model viewer
245 add_executable(pofview
252 target_link_libraries(
258 ${wxWidgets_LIBRARIES}
259 ${PLATFORM_LIBRARIES}
262 # wxWidgets appears to need c++11 for one or more headers
264 set_target_properties(pofview PROPERTIES COMPILE_FLAGS -std=c++11)
268 # SCRAMBLE: file-based encryption for TBLs
271 add_executable(scramble
278 # FONTTOOL: create font files / edit kerning data
281 add_executable(fonttool
288 # background setup, to allow running from build location without installing
289 add_custom_command(TARGET fonttool
291 COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/src/fonttool"
292 COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/src/fonttool/fonttool.pcx" "${CMAKE_CURRENT_BINARY_DIR}/src/fonttool"
295 target_link_libraries(
301 ${PLATFORM_LIBRARIES}
305 # custom target to build all tools in one pass
308 add_custom_target(tools)
310 add_dependencies(tools
321 # ##############################################################################
324 # optionally include any dev/user preferred build commands and/or options
327 include(custom.cmake OPTIONAL)