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")
13 include(CreateSourceGroups)
16 # ##############################################################################
18 option(FS1 "Build original FreeSpace" OFF)
19 option(DEMO "Create demo build" OFF)
21 if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
22 message(STATUS "Setting build type to 'Debug' as none was specified.")
23 set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
24 # Set the possible values of build type for cmake-gui
25 set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
26 "MinSizeRel" "RelWithDebInfo")
31 add_definitions(-DMAKE_FS1)
34 add_definitions(-DDEMO -DFS1_DEMO)
38 add_definitions(-DFS2_DEMO)
43 set(PLATFORM_LIBRARIES "")
45 add_definitions(-DPLAT_UNIX)
46 add_definitions(-Wall)
47 # add_definitions(-Wno-format-y2k)
48 # add_definitions(-Wno-deprecated)
49 add_definitions(-fsigned-char)
51 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DNDEBUG -g -O2")
52 set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -DNDEBUG -Os")
53 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -O2")
54 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3")
56 set(SDL2DIR "${CMAKE_SOURCE_DIR}/../Support/SDL2" CACHE PATH "Path to SDL2")
57 set(OPENALDIR "${CMAKE_SOURCE_DIR}/../Support/OpenAL" CACHE PATH "Path to OpenAL")
58 set(LWSDIR "${CMAKE_SOURCE_DIR}/../Support/libwebsockets" CACHE PATH "Path to libwebsockets")
59 set(WXWIDGETSDIR "${CMAKE_SOURCE_DIR}/../Support/wxWidgets" CACHE PATH "Path to wxWidgets")
60 set(ANGLEDIR "${CMAKE_SOURCE_DIR}/../Support/ANGLE" CACHE PATH "Path to ANGLE")
62 set(PLATFORM_LIBRARIES
64 ${ANGLEDIR}/lib/libEGL.lib
65 ${ANGLEDIR}/lib/libGLESv2.lib
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, ...
82 set(BIN_SUFFIX "${BIN_SUFFIX}demo")
85 find_package(SDL2 "2.0.1" REQUIRED)
86 find_package(OpenGL REQUIRED)
87 find_package(OpenAL REQUIRED)
88 find_package(LibWebSockets REQUIRED)
90 find_package(wxWidgets COMPONENTS core base gl net)
91 include(${wxWidgets_USE_FILE})
93 # ##############################################################################
97 ${PROJECT_SOURCE_DIR}/include
100 ${LIBWEBSOCKETS_INCLUDE_DIR}
101 ${wxWidgets_INCLUDE_DIRS}
105 add_subdirectory(src)
106 add_subdirectory(include)
109 # ##############################################################################
113 # main code/game library
124 CreateSourceGroups(${code_SOURCE} ${platform_SOURCE})
130 set(FS_BINARY "fs${BIN_SUFFIX}")
132 add_executable(${FS_BINARY}
138 CreateSourceGroups(${freespace_SOURCE})
140 target_link_libraries(
146 ${LIBWEBSOCKETS_LIBRARIES}
147 ${PLATFORM_LIBRARIES}
151 set_target_properties(${FS_BINARY} PROPERTIES PROJECT_LABEL "Freespace")
153 set_target_properties(${FS_BINARY} PROPERTIES PROJECT_LABEL "Freespace2")
160 set(LAUNCHER_BINARY "freespace${BIN_SUFFIX}")
162 add_executable(${LAUNCHER_BINARY}
168 CreateSourceGroups(${launcher_SOURCE})
170 target_link_libraries(
175 ${wxWidgets_LIBRARIES}
176 ${PLATFORM_LIBRARIES}
179 set_target_properties(${LAUNCHER_BINARY} PROPERTIES PROJECT_LABEL "Launcher")
181 # wxWidgets appears to need c++11 for one or more headers
183 set_target_properties(${LAUNCHER_BINARY} PROPERTIES COMPILE_FLAGS -std=c++11)
187 # standalone server GUI
191 set(STANDALONE_BINARY fsstandalone)
193 set(STANDALONE_BINARY fs2standalone)
196 add_executable(${STANDALONE_BINARY}
199 ${standalone_HEADERS}
202 CreateSourceGroups(${standalone_SOURCE})
204 target_link_libraries(
207 ${wxWidgets_LIBRARIES}
208 ${LIBWEBSOCKETS_LIBRARIES}
209 ${PLATFORM_LIBRARIES}
212 set_target_properties(${STANDALONE_BINARY} PROPERTIES PROJECT_LABEL "Standalone")
214 # wxWidgets appears to need c++11 for one or more headers
216 set_target_properties(${STANDALONE_BINARY} PROPERTIES COMPILE_FLAGS -std=c++11)
220 # ##############################################################################
222 # ##############################################################################
224 # toolset: targets for creating/modifying game assets
237 CreateSourceGroups(${ac_SOURCE})
239 target_link_libraries(
245 ${LIBWEBSOCKETS_LIBRARIES}
246 ${PLATFORM_LIBRARIES}
250 # CFILEARCHIVER: to create VP file archives
253 add_executable(cfilearchiver
255 ${cfilearchiver_SOURCE}
258 CreateSourceGroups(${cfilearchiver_SOURCE})
261 # CRYPTSTRING: string encryption (for embedded cheat codes)
264 add_executable(cryptstring
266 ${cryptstring_SOURCE}
269 CreateSourceGroups(${cryptstring_SOURCE})
272 # NEBEDIT: FS1 style nebula editor/creator
275 add_executable(nebedit
281 CreateSourceGroups(${nebedit_SOURCE})
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(nebedit PROPERTIES COMPILE_FLAGS -std=c++11)
300 # POFVIEW: model viewer
303 add_executable(pofview
310 CreateSourceGroups(${pofview_SOURCE})
312 target_link_libraries(
318 ${wxWidgets_LIBRARIES}
319 ${LIBWEBSOCKETS_LIBRARIES}
320 ${PLATFORM_LIBRARIES}
323 # wxWidgets appears to need c++11 for one or more headers
325 set_target_properties(pofview PROPERTIES COMPILE_FLAGS -std=c++11)
329 # SCRAMBLE: file-based encryption for TBLs
332 add_executable(scramble
338 CreateSourceGroups(${scramble_SOURCE})
341 # FONTTOOL: create font files / edit kerning data
344 add_executable(fonttool
350 CreateSourceGroups(${fonttool_SOURCE})
352 # background setup, to allow running from build location without installing
353 add_custom_command(TARGET fonttool
355 COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/src/fonttool"
356 COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/src/fonttool/fonttool.pcx" "${CMAKE_CURRENT_BINARY_DIR}/src/fonttool"
359 target_link_libraries(
365 ${LIBWEBSOCKETS_LIBRARIES}
366 ${PLATFORM_LIBRARIES}
370 # custom target to build all tools in one pass
373 add_custom_target(tools)
375 add_dependencies(tools
386 # ##############################################################################
389 # optionally include any dev/user preferred build commands and/or options
392 include(custom.cmake OPTIONAL)