]> icculus.org git repositories - taylor/freespace2.git/blob - CMakeLists.txt
stub out gr_string_win(), can't ever use it as-is
[taylor/freespace2.git] / CMakeLists.txt
1
2 project(freespace2)
3
4 cmake_minimum_required(VERSION 2.8)
5
6 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
7
8
9 find_package(SDL2 "2.0.1" REQUIRED)
10 find_package(OpenGL REQUIRED)
11 find_package(OpenAL REQUIRED)
12
13 find_package(wxWidgets COMPONENTS core base gl)
14 include(${wxWidgets_USE_FILE})
15
16
17 # ##############################################################################
18
19 option(FS1 "Build original FreeSpace" OFF)
20 option(DEMO "Create demo build" OFF)
21
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")
28 endif()
29
30
31 if(FS1)
32   add_definitions(-DMAKE_FS1)
33
34   if(DEMO)
35         add_definitions(-DDEMO -DFS1_DEMO)
36   endif()
37 else()
38   if(DEMO)
39         add_definitions(-DFS2_DEMO)
40   endif()
41 endif()
42
43 if(NOT WIN32)
44   add_definitions(-DPLAT_UNIX)
45   add_definitions(-Wall -Wno-format-y2k -Wno-deprecated)
46   add_definitions(-fsigned-char)
47
48   set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DNDEBUG -g -O2")
49   set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -DNDEBUG -Os")
50   set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -O2")
51   set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3")
52 endif()
53
54 # ##############################################################################
55
56
57 include_directories(
58   ${PROJECT_SOURCE_DIR}/include
59   ${SDL2_INCLUDE_DIR}
60   ${OPENAL_INCLUDE_DIR}
61   ${wxWidgets_INCLUDE_DIRS}
62 )
63
64
65 add_subdirectory(src)
66 add_subdirectory(include)
67
68
69 # ##############################################################################
70 #
71
72 #
73 # main code/game library
74 #
75
76 add_library(code
77   STATIC
78   ${code_SOURCE}
79   ${code_HEADERS}
80   ${platform_SOURCE}
81 )
82
83 #
84 # the game itself
85 #
86
87 if(FS1)
88   if(DEMO)
89     set(FS_BINARY freespace_demo)
90   else()
91     set(FS_BINARY freespace)
92   endif()
93 else()
94   if(DEMO)
95     set(FS_BINARY freespace2_demo)
96   else()
97         set(FS_BINARY freespace2)
98   endif()
99 endif()
100
101 add_executable(${FS_BINARY}
102   ${freespace_SOURCE}
103   ${freespace_HEADERS}
104 )
105
106 target_link_libraries(
107   ${FS_BINARY}
108   code
109   ${SDL2_LIBRARY}
110   ${OPENGL_LIBRARIES}
111   ${OPENAL_LIBRARY}
112 )
113
114 #
115 # ##############################################################################
116
117 # ##############################################################################
118 #
119 # toolset: targets for creating/modifying game assets
120 #
121
122 #
123 # AC: anim converter
124 #
125
126 add_executable(ac
127   EXCLUDE_FROM_ALL
128   ${ac_SOURCE}
129   ${ac_HEADERS}
130 )
131
132 target_link_libraries(
133   ac
134   code
135   ${SDL2_LIBRARY}
136   ${OPENGL_LIBRARIES}
137   ${OPENAL_LIBRARY}
138 )
139
140 #
141 # CFILEARCHIVER: to create VP file archives
142 #
143
144 add_executable(cfilearchiver
145   EXCLUDE_FROM_ALL
146   ${cfilearchiver_SOURCE}
147 )
148
149 #
150 # CRYPTSTRING: string encryption (for embedded cheat codes)
151 #
152
153 add_executable(cryptstring
154   EXCLUDE_FROM_ALL
155   ${cryptstring_SOURCE}
156 )
157
158 #
159 # NEBEDIT: FS1 style nebula editor/creator
160 #
161
162 add_executable(nebedit
163   EXCLUDE_FROM_ALL
164   ${nebedit_SOURCE}
165 )
166
167 target_link_libraries(
168   nebedit
169   code
170   ${SDL2_LIBRARY}
171   ${OPENGL_LIBRARIES}
172   ${OPENAL_LIBRARY}
173   ${wxWidgets_LIBRARIES}
174 )
175
176 #
177 # POFVIEW: model viewer
178 #
179
180 add_executable(pofview
181   EXCLUDE_FROM_ALL
182   ${pofview_SOURCE}
183   ${pofview_HEADERS}
184 )
185
186 target_link_libraries(
187   pofview
188   code
189   ${SDL2_LIBRARY}
190   ${OPENGL_LIBRARIES}
191   ${OPENAL_LIBRARY}
192   ${wxWidgets_LIBRARIES}
193 )
194
195 # wxWidgets appears to need c++11 for one or more headers
196 if(NOT WIN32)
197   set_target_properties(pofview PROPERTIES COMPILE_FLAGS -std=c++11)
198 endif()
199
200 #
201 # SCRAMBLE: file-based encryption for TBLs
202 #
203
204 add_executable(scramble
205   EXCLUDE_FROM_ALL
206   ${scramble_SOURCE}
207   ${scramble_HEADERS}
208 )
209
210 #
211 # FONTTOOL: create font files / edit kerning data
212 #
213
214 add_executable(fonttool
215   EXCLUDE_FROM_ALL
216   ${fonttool_SOURCE}
217   ${fonttool_HEADERS}
218 )
219
220 # background setup, to allow running from build location without installing
221 add_custom_command(TARGET fonttool
222   POST_BUILD
223   COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/src/fonttool"
224   COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/src/fonttool/fonttool.pcx" "${CMAKE_CURRENT_BINARY_DIR}/src/fonttool"
225 )
226
227 target_link_libraries(
228   fonttool
229   code
230   ${SDL2_LIBRARY}
231   ${OPENGL_LIBRARIES}
232   ${OPENAL_LIBRARY}
233 )
234
235 #
236 # custom target to build all tools in one pass
237 #
238
239 add_custom_target(tools)
240
241 add_dependencies(tools
242   ac
243   cfilearchiver
244   cryptstring
245   nebedit
246   pofview
247   scramble
248   fonttool
249 )
250
251 #
252 # ##############################################################################
253
254 #
255 # optionally include any dev/user preferred build commands and/or options
256 #
257
258 include(custom.cmake OPTIONAL)