4 cmake_minimum_required(VERSION 2.6)
7 include(CheckCXXCompilerFlag)
8 include(CheckCXXSourceCompiles)
10 include(FindPkgConfig)
12 pkg_search_module(SDL2 REQUIRED sdl2 >= 2.0.1)
16 find_package(wxWidgets COMPONENTS core base gl)
18 include(${wxWidgets_USE_FILE})
21 # ##############################################################################
23 option(FS1 "Build original FreeSpace" OFF)
24 option(DEMO "Create demo build" OFF)
26 if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
27 message(STATUS "Setting build type to 'Debug' as none was specified.")
28 set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
29 # Set the possible values of build type for cmake-gui
30 set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
31 "MinSizeRel" "RelWithDebInfo")
36 add_definitions(-DMAKE_FS1)
39 add_definitions(-DDEMO -DFS1_DEMO)
43 add_definitions(-DFS2_DEMO)
48 add_definitions(-DPLAT_UNIX)
49 add_definitions(-Wall -Wno-format-y2k -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")
58 # ##############################################################################
62 ${PROJECT_SOURCE_DIR}/include
65 ${wxWidgets_INCLUDE_DIRS}
70 add_subdirectory(include)
73 # ##############################################################################
77 # main code/game library
92 set(FS_BINARY freespace_demo)
94 set(FS_BINARY freespace)
98 set(FS_BINARY freespace2_demo)
100 set(FS_BINARY freespace2)
104 add_executable(${FS_BINARY}
109 target_link_libraries(
118 # ##############################################################################
120 # ##############################################################################
122 # toolset: targets for creating/modifying game assets
135 target_link_libraries(
144 # CFILEARCHIVER: to create VP file archives
147 add_executable(cfilearchiver
149 ${cfilearchiver_SOURCE}
153 # CRYPTSTRING: string encryption (for embedded cheat codes)
156 add_executable(cryptstring
158 ${cryptstring_SOURCE}
162 # NEBEDIT: FS1 style nebula editor/creator
165 add_executable(nebedit
170 target_link_libraries(
176 ${wxWidgets_LIBRARIES}
180 # POFVIEW: model viewer
183 add_executable(pofview
189 target_link_libraries(
195 ${wxWidgets_LIBRARIES}
198 # wxWidgets appears to need c++11 for one or more headers
200 set_target_properties(pofview PROPERTIES COMPILE_FLAGS -std=c++11)
204 # SCRAMBLE: file-based encryption for TBLs
207 add_executable(scramble
214 # FONTTOOL: create font files / edit kerning data
217 add_executable(fonttool
223 # background setup, to allow running from build location without installing
224 add_custom_command(TARGET fonttool
226 COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/src/fonttool"
227 COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/src/fonttool/fonttool.pcx" "${CMAKE_CURRENT_BINARY_DIR}/src/fonttool"
230 target_link_libraries(
239 # custom target to build all tools in one pass
242 add_custom_target(tools)
244 add_dependencies(tools
255 # ##############################################################################
258 # optionally include any dev/user preferred build commands and/or options
261 include(custom.cmake OPTIONAL)