4 cmake_minimum_required(VERSION 2.8)
6 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
9 find_package(SDL2 "2.0.1" REQUIRED)
10 find_package(OpenGL REQUIRED)
11 find_package(OpenAL REQUIRED)
13 find_package(wxWidgets COMPONENTS core base gl)
14 include(${wxWidgets_USE_FILE})
17 # ##############################################################################
19 option(FS1 "Build original FreeSpace" OFF)
20 option(DEMO "Create demo build" OFF)
22 if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
23 message(STATUS "Setting build type to 'Debug' as none was specified.")
24 set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
25 # Set the possible values of build type for cmake-gui
26 set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
27 "MinSizeRel" "RelWithDebInfo")
32 add_definitions(-DMAKE_FS1)
35 add_definitions(-DDEMO -DFS1_DEMO)
39 add_definitions(-DFS2_DEMO)
44 set(PLATFORM_LIBRARIES "")
46 add_definitions(-DPLAT_UNIX)
47 add_definitions(-Wall)
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(PLATFORM_LIBRARIES
62 add_definitions(/D _CRT_SECURE_NO_WARNINGS)
64 add_definitions(/wd4100) # unreferenced parameter
65 add_definitions(/wd4127) # conditional expression is constant: do { } while (0)
66 add_definitions(/wd4611) # non-portable interaction between setjmp() and C++ object destruction
67 add_definitions(/wd4996) # deprecated functions: fopen, fileno, ...
71 # ##############################################################################
75 ${PROJECT_SOURCE_DIR}/include
78 ${wxWidgets_INCLUDE_DIRS}
83 add_subdirectory(include)
86 # ##############################################################################
90 # main code/game library
107 set(FS_BINARY freespace_demo)
109 set(FS_BINARY freespace)
113 set(FS_BINARY freespace2_demo)
115 set(FS_BINARY freespace2)
119 add_executable(${FS_BINARY}
125 target_link_libraries(
131 ${PLATFORM_LIBRARIES}
135 # ##############################################################################
137 # ##############################################################################
139 # toolset: targets for creating/modifying game assets
152 target_link_libraries(
158 ${PLATFORM_LIBRARIES}
162 # CFILEARCHIVER: to create VP file archives
165 add_executable(cfilearchiver
167 ${cfilearchiver_SOURCE}
171 # CRYPTSTRING: string encryption (for embedded cheat codes)
174 add_executable(cryptstring
176 ${cryptstring_SOURCE}
180 # NEBEDIT: FS1 style nebula editor/creator
183 add_executable(nebedit
189 target_link_libraries(
195 ${wxWidgets_LIBRARIES}
196 ${PLATFORM_LIBRARIES}
199 # wxWidgets appears to need c++11 for one or more headers
201 set_target_properties(nebedit PROPERTIES COMPILE_FLAGS -std=c++11)
205 # POFVIEW: model viewer
208 add_executable(pofview
215 target_link_libraries(
221 ${wxWidgets_LIBRARIES}
222 ${PLATFORM_LIBRARIES}
225 # wxWidgets appears to need c++11 for one or more headers
227 set_target_properties(pofview PROPERTIES COMPILE_FLAGS -std=c++11)
231 # SCRAMBLE: file-based encryption for TBLs
234 add_executable(scramble
241 # FONTTOOL: create font files / edit kerning data
244 add_executable(fonttool
251 # background setup, to allow running from build location without installing
252 add_custom_command(TARGET fonttool
254 COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/src/fonttool"
255 COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/src/fonttool/fonttool.pcx" "${CMAKE_CURRENT_BINARY_DIR}/src/fonttool"
258 target_link_libraries(
264 ${PLATFORM_LIBRARIES}
268 # custom target to build all tools in one pass
271 add_custom_target(tools)
273 add_dependencies(tools
284 # ##############################################################################
287 # optionally include any dev/user preferred build commands and/or options
290 include(custom.cmake OPTIONAL)