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(-Wshadow)
48 # add_definitions(-Wno-format-y2k)
49 # add_definitions(-Wno-deprecated)
50 add_definitions(-fsigned-char)
52 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DNDEBUG -g -O2")
53 set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -DNDEBUG -Os")
54 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -O2")
55 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3")
57 set(SDL2DIR "${CMAKE_SOURCE_DIR}/../Support/SDL2" CACHE PATH "Path to SDL2")
58 set(OPENALDIR "${CMAKE_SOURCE_DIR}/../Support/OpenAL" CACHE PATH "Path to OpenAL")
59 set(LWSDIR "${CMAKE_SOURCE_DIR}/../Support/libwebsockets" CACHE PATH "Path to libwebsockets")
60 set(WXWIDGETSDIR "${CMAKE_SOURCE_DIR}/../Support/wxWidgets" CACHE PATH "Path to wxWidgets")
61 set(ANGLEDIR "${CMAKE_SOURCE_DIR}/../Support/ANGLE" CACHE PATH "Path to ANGLE")
63 set(PLATFORM_LIBRARIES
65 ${ANGLEDIR}/lib/libEGL.lib
66 ${ANGLEDIR}/lib/libGLESv2.lib
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, ...
83 set(BIN_SUFFIX "${BIN_SUFFIX}demo")
86 find_package(SDL2 "2.0.2" REQUIRED)
87 find_package(OpenGL REQUIRED)
88 find_package(OpenAL REQUIRED)
89 find_package(LibWebSockets REQUIRED)
91 find_package(wxWidgets COMPONENTS core base gl net)
92 include(${wxWidgets_USE_FILE})
94 # ##############################################################################
98 ${PROJECT_SOURCE_DIR}/include
100 ${OPENAL_INCLUDE_DIR}
101 ${LIBWEBSOCKETS_INCLUDE_DIR}
102 ${wxWidgets_INCLUDE_DIRS}
106 add_subdirectory(src)
107 add_subdirectory(include)
110 # ##############################################################################
114 # main code/game library
125 CreateSourceGroups(${code_SOURCE} ${platform_SOURCE})
131 set(FS_BINARY "fs${BIN_SUFFIX}")
133 add_executable(${FS_BINARY}
139 CreateSourceGroups(${freespace_SOURCE})
141 target_link_libraries(
147 ${LIBWEBSOCKETS_LIBRARIES}
148 ${PLATFORM_LIBRARIES}
152 set_target_properties(${FS_BINARY} PROPERTIES PROJECT_LABEL "Freespace")
154 set_target_properties(${FS_BINARY} PROPERTIES PROJECT_LABEL "Freespace2")
161 set(LAUNCHER_BINARY "freespace${BIN_SUFFIX}")
163 add_executable(${LAUNCHER_BINARY}
169 CreateSourceGroups(${launcher_SOURCE})
171 target_link_libraries(
176 ${wxWidgets_LIBRARIES}
177 ${PLATFORM_LIBRARIES}
180 set_target_properties(${LAUNCHER_BINARY} PROPERTIES PROJECT_LABEL "Launcher")
182 # wxWidgets appears to need c++11 for one or more headers
184 set_target_properties(${LAUNCHER_BINARY} PROPERTIES COMPILE_FLAGS -std=c++11)
188 # standalone server GUI
192 set(STANDALONE_BINARY fsstandalone)
194 set(STANDALONE_BINARY fs2standalone)
197 add_executable(${STANDALONE_BINARY}
200 ${standalone_HEADERS}
203 CreateSourceGroups(${standalone_SOURCE})
205 target_link_libraries(
208 ${wxWidgets_LIBRARIES}
209 ${LIBWEBSOCKETS_LIBRARIES}
210 ${PLATFORM_LIBRARIES}
213 set_target_properties(${STANDALONE_BINARY} PROPERTIES PROJECT_LABEL "Standalone")
215 # wxWidgets appears to need c++11 for one or more headers
217 set_target_properties(${STANDALONE_BINARY} PROPERTIES COMPILE_FLAGS -std=c++11)
221 # ##############################################################################
223 # ##############################################################################
225 # toolset: targets for creating/modifying game assets
238 CreateSourceGroups(${ac_SOURCE})
240 target_link_libraries(
246 ${LIBWEBSOCKETS_LIBRARIES}
247 ${PLATFORM_LIBRARIES}
251 # CFILEARCHIVER: to create VP file archives
254 add_executable(cfilearchiver
256 ${cfilearchiver_SOURCE}
259 CreateSourceGroups(${cfilearchiver_SOURCE})
262 # CRYPTSTRING: string encryption (for embedded cheat codes)
265 add_executable(cryptstring
267 ${cryptstring_SOURCE}
270 CreateSourceGroups(${cryptstring_SOURCE})
273 # NEBEDIT: FS1 style nebula editor/creator
276 add_executable(nebedit
282 CreateSourceGroups(${nebedit_SOURCE})
284 target_link_libraries(
290 ${wxWidgets_LIBRARIES}
291 ${LIBWEBSOCKETS_LIBRARIES}
292 ${PLATFORM_LIBRARIES}
295 # wxWidgets appears to need c++11 for one or more headers
297 set_target_properties(nebedit PROPERTIES COMPILE_FLAGS -std=c++11)
301 # POFVIEW: model viewer
304 add_executable(pofview
311 CreateSourceGroups(${pofview_SOURCE})
313 target_link_libraries(
319 ${wxWidgets_LIBRARIES}
320 ${LIBWEBSOCKETS_LIBRARIES}
321 ${PLATFORM_LIBRARIES}
324 # wxWidgets appears to need c++11 for one or more headers
326 set_target_properties(pofview PROPERTIES COMPILE_FLAGS -std=c++11)
330 # SCRAMBLE: file-based encryption for TBLs
333 add_executable(scramble
339 CreateSourceGroups(${scramble_SOURCE})
342 # FONTTOOL: create font files / edit kerning data
345 add_executable(fonttool
351 CreateSourceGroups(${fonttool_SOURCE})
353 # background setup, to allow running from build location without installing
354 add_custom_command(TARGET fonttool
356 COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/src/fonttool"
357 COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/src/fonttool/fonttool.pcx" "${CMAKE_CURRENT_BINARY_DIR}/src/fonttool"
360 target_link_libraries(
366 ${LIBWEBSOCKETS_LIBRARIES}
367 ${PLATFORM_LIBRARIES}
371 # custom target to build all tools in one pass
374 add_custom_target(tools)
376 add_dependencies(tools
387 # ##############################################################################
390 # optionally include any dev/user preferred build commands and/or options
393 include(custom.cmake OPTIONAL)