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)
18 find_package(wxWidgets COMPONENTS core base gl)
19 include(${wxWidgets_USE_FILE})
22 # ##############################################################################
24 option(FS1 "Build original FreeSpace" OFF)
25 option(DEMO "Create demo build" OFF)
27 if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
28 message(STATUS "Setting build type to 'Debug' as none was specified.")
29 set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
30 # Set the possible values of build type for cmake-gui
31 set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
32 "MinSizeRel" "RelWithDebInfo")
37 add_definitions(-DMAKE_FS1)
40 add_definitions(-DDEMO -DFS1_DEMO)
44 add_definitions(-DFS2_DEMO)
49 set(PLATFORM_LIBRARIES "")
51 add_definitions(-DPLAT_UNIX)
52 add_definitions(-Wall)
53 # add_definitions(-Wno-format-y2k)
54 # add_definitions(-Wno-deprecated)
55 add_definitions(-fsigned-char)
57 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DNDEBUG -g -O2")
58 set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -DNDEBUG -Os")
59 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -O2")
60 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3")
62 set(PLATFORM_LIBRARIES
67 add_definitions(/D _CRT_SECURE_NO_WARNINGS)
69 add_definitions(/wd4100) # unreferenced parameter
70 add_definitions(/wd4127) # conditional expression is constant: do { } while (0)
71 add_definitions(/wd4996) # deprecated functions: fopen, fileno, ...
75 # ##############################################################################
79 ${PROJECT_SOURCE_DIR}/include
82 ${wxWidgets_INCLUDE_DIRS}
87 add_subdirectory(include)
90 # ##############################################################################
94 # main code/game library
111 set(FS_BINARY freespace_demo)
113 set(FS_BINARY freespace)
117 set(FS_BINARY freespace2_demo)
119 set(FS_BINARY freespace2)
123 add_executable(${FS_BINARY}
129 target_link_libraries(
135 ${PLATFORM_LIBRARIES}
139 # ##############################################################################
141 # ##############################################################################
143 # toolset: targets for creating/modifying game assets
156 target_link_libraries(
162 ${PLATFORM_LIBRARIES}
166 # CFILEARCHIVER: to create VP file archives
169 add_executable(cfilearchiver
171 ${cfilearchiver_SOURCE}
175 # CRYPTSTRING: string encryption (for embedded cheat codes)
178 add_executable(cryptstring
180 ${cryptstring_SOURCE}
184 # NEBEDIT: FS1 style nebula editor/creator
187 add_executable(nebedit
193 target_link_libraries(
199 ${wxWidgets_LIBRARIES}
200 ${PLATFORM_LIBRARIES}
203 # wxWidgets appears to need c++11 for one or more headers
205 set_target_properties(nebedit PROPERTIES COMPILE_FLAGS -std=c++11)
209 # POFVIEW: model viewer
212 add_executable(pofview
219 target_link_libraries(
225 ${wxWidgets_LIBRARIES}
226 ${PLATFORM_LIBRARIES}
229 # wxWidgets appears to need c++11 for one or more headers
231 set_target_properties(pofview PROPERTIES COMPILE_FLAGS -std=c++11)
235 # SCRAMBLE: file-based encryption for TBLs
238 add_executable(scramble
245 # FONTTOOL: create font files / edit kerning data
248 add_executable(fonttool
255 # background setup, to allow running from build location without installing
256 add_custom_command(TARGET fonttool
258 COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/src/fonttool"
259 COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/src/fonttool/fonttool.pcx" "${CMAKE_CURRENT_BINARY_DIR}/src/fonttool"
262 target_link_libraries(
268 ${PLATFORM_LIBRARIES}
272 # custom target to build all tools in one pass
275 add_custom_target(tools)
277 add_dependencies(tools
288 # ##############################################################################
291 # optionally include any dev/user preferred build commands and/or options
294 include(custom.cmake OPTIONAL)