forked from solarus-games/solarus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
234 lines (209 loc) · 6.28 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
cmake_minimum_required(VERSION 2.6)
project(SOLARUS_ENGINE)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif()
set(CMAKE_MODULE_PATH "${SOLARUS_ENGINE_SOURCE_DIR}/cmake/modules/")
set(SOLARUS_INSTALL_DESTINATION "bin")
# find the headers and the libraries of dependencies
find_package(SDL REQUIRED)
find_package(SDL_image REQUIRED)
find_package(SDL_ttf REQUIRED)
find_package(OpenAL REQUIRED)
find_package(VorbisFile REQUIRED)
find_package(Ogg REQUIRED)
find_package(ModPlug REQUIRED)
find_package(Lua51 REQUIRED)
find_package(PhysFS REQUIRED)
# Explicit link to libdl is needed for Lua on some systems.
find_library(DL_LIBRARY dl)
if(${DL_LIBRARY} MATCHES DL_LIBRARY-NOTFOUND)
set(DL_LIBRARY "")
endif()
include(CheckFunctionExists)
check_function_exists(mkstemp HAVE_MKSTEMP)
configure_file(${CMAKE_SOURCE_DIR}/include/config.h.in ${CMAKE_BINARY_DIR}/include/config.h)
include(CheckIncludeFiles)
check_include_files(unistd.h HAVE_UNISTD_H)
configure_file(${CMAKE_SOURCE_DIR}/include/config.h.in ${CMAKE_BINARY_DIR}/include/config.h)
# source files
file(
GLOB
source_files
src/*.cpp
src/entities/*.cpp
src/hero/*.cpp
src/hud/*.cpp
src/lowlevel/*.cpp
src/lua/*.cpp
src/menus/*.cpp
src/movements/*.cpp
src/snes_spc/*.cpp
include/*.h
include/entities/*.h
include/hero/*.h
include/hud/*.h
include/lowlevel/*.h
include/lua/*.h
include/menus/*.h
include/movements/*.h
include/snes_spc/*.h
)
# Configuration for OSX and iOS build and deployment
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if(NOT SOLARUS_IOS_BUILD)
include(OSX)
else()
include(iOS)
endif()
endif()
# additional source files for Apple systems
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(source_files
${source_files}
src/lowlevel/apple/AppleInterface.mm
include/lowlevel/apple/AppleInterface.h
)
# SDL 1.3 avoid to link SDLMain
if(SDL_VERSION VERSION_LESS "1.3")
set(source_files
${source_files}
src/lowlevel/apple/SDLMain.m
include/lowlevel/apple/SDLMain.h
)
endif()
endif()
# build the executable
set(main_source_file src/lowlevel/Main.cc)
add_library(solarus_static
STATIC
${source_files}
)
#Add executable target, into CFBundle form if requested or iOS build
if(SOLARUS_BUNDLE OR SOLARUS_IOS_BUILD)
include(addCFBundleTarget)
else()
add_executable(solarus
${main_source_file}
)
endif()
# generate -I flags
include_directories(
${CMAKE_BINARY_DIR}/include
${SOLARUS_ENGINE_SOURCE_DIR}/include
${SOLARUS_ENGINE_SOURCE_DIR}/include/snes_spc
${SDL_INCLUDE_DIR}
${SDLTTF_INCLUDE_DIR}
${SDLIMAGE_INCLUDE_DIR}
${OPENAL_INCLUDE_DIR}
${VORBISFILE_INCLUDE_DIR}
${OGG_INCLUDE_DIR}
${MODPLUG_INCLUDE_DIR}
${LUA_INCLUDE_DIR}
${PHYSFS_INCLUDE_DIR}
)
# generate -l flags
target_link_libraries(solarus
solarus_static
${SDL_LIBRARY}
${SDLIMAGE_LIBRARY}
${SDLTTF_LIBRARY}
${OPENAL_LIBRARY}
${LUA_LIBRARY}
${DL_LIBRARY}
${PHYSFS_LIBRARY}
${VORBISFILE_LIBRARY}
${OGG_LIBRARY}
${MODPLUG_LIBRARY}
)
# default compilation flags
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Release")
# Force to be the less pedantic possible with the Release build
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error -Wno-all -Wno-unknown-pragmas")
# Some "no-warning" flags are not supported with gcc < 4.0
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
exec_program(gcc ARGS --version OUTPUT_VARIABLE CMAKE_C_COMPILER_VERSION)
if(NOT CMAKE_C_COMPILER_VERSION MATCHES "(^|[^\\.])[0-3]\\.[0-9]")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-fatal-errors -Wno-extra")
endif()
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-fatal-errors -Wno-extra")
endif()
else()
set(CMAKE_CXX_FLAGS "-Wall ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "-Werror ${CMAKE_CXX_FLAGS_DEBUG}")
endif()
set(DEFAULT_QUEST "." CACHE STRING "Path to the quest to launch if none is specified at runtime.")
if(DEFAULT_QUEST)
add_definitions(-DSOLARUS_DEFAULT_QUEST=\"${DEFAULT_QUEST}\")
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(INITIAL_WRITE_DIR "Solarus")
else()
set(INITIAL_WRITE_DIR ".solarus")
endif()
set(WRITE_DIR ${INITIAL_WRITE_DIR} CACHE STRING "Directory where Solarus savegames are stored, relative to the user's base write directory.")
if(WRITE_DIR)
add_definitions(-DSOLARUS_WRITE_DIR=\"${WRITE_DIR}\")
endif()
if(PANDORA)
set(INITIAL_DEFAULT_QUEST_WIDTH 400)
else()
set(INITIAL_DEFAULT_QUEST_WIDTH 320)
endif()
set(DEFAULT_QUEST_WIDTH ${INITIAL_DEFAULT_QUEST_WIDTH} CACHE INTEGER "Default width of the quest screen in pixels.")
set(DEFAULT_QUEST_HEIGHT 240 CACHE INTEGER "Default height of the quest screen in pixels.")
if(DEFAULT_QUEST_WIDTH)
add_definitions(-DSOLARUS_DEFAULT_QUEST_WIDTH=${DEFAULT_QUEST_WIDTH})
endif()
if(DEFAULT_QUEST_HEIGHT)
add_definitions(-DSOLARUS_DEFAULT_QUEST_HEIGHT=${DEFAULT_QUEST_HEIGHT})
endif()
if(GCWZERO)
add_definitions(-DGCWZERO)
endif()
if(CAANOO OR GCWZERO)
set(INITIAL_COLOR_DEPTH 16)
else()
set(INITIAL_COLOR_DEPTH 32)
endif()
set(COLOR_DEPTH ${INITIAL_COLOR_DEPTH} CACHE INTEGER "Number of bits per pixel for surfaces.")
if(COLOR_DEPTH)
add_definitions(-DSOLARUS_COLOR_DEPTH=${COLOR_DEPTH})
endif()
if(CAANOO OR GCWZERO)
set(INITIAL_SCREEN_FORCE_MODE 2) # Windowed normal.
elseif(PANDORA)
set(INITIAL_SCREEN_FORCE_MODE 3) # Fullscreen normal.
else()
set(INITIAL_SCREEN_FORCE_MODE -1)
endif()
set(SCREEN_FORCE_MODE ${INITIAL_SCREEN_FORCE_MODE} CACHE INTEGER "Video mode to force (-1 means no restriction).")
if(SCREEN_FORCE_MODE)
add_definitions(-DSOLARUS_SCREEN_FORCE_MODE=${SCREEN_FORCE_MODE})
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(INITIAL_SCREEN_DOUBLEBUF OFF)
else()
set(INITIAL_SCREEN_DOUBLEBUF ON)
endif()
option(SCREEN_DOUBLEBUF "Define if your plaform supports double buffering." ${INITIAL_SCREEN_DOUBLEBUF})
if(SCREEN_DOUBLEBUF)
add_definitions(-DSOLARUS_SCREEN_DOUBLEBUF)
endif()
# files to install with make install
# install the bundle if requested, or only the binary else
if(SOLARUS_BUNDLE)
install(TARGETS solarus
BUNDLE DESTINATION ${SOLARUS_INSTALL_DESTINATION}
)
else()
install(TARGETS solarus
RUNTIME DESTINATION ${SOLARUS_INSTALL_DESTINATION}
)
endif()