This repository has been archived by the owner on Jun 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 133
/
CMakeLists.txt
172 lines (155 loc) · 4.74 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
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/")
# 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)
# 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/simpleini/*.h
include/snes_spc/*.h
)
# additional source files for Mac OS
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
include_directories(
${SOLARUS_ENGINE_SOURCE_DIR}/include/lowlevel/osx
)
set(source_files
${source_files}
src/lowlevel/osx/SDLMain.m
include/lowlevel/osx/SDLMain.h
)
endif()
# build the executable
set(main_source_file src/lowlevel/Main.cc)
add_library(solarus_static
STATIC
${source_files}
)
add_executable(solarus
${main_source_file}
)
# generate -I flags
include_directories(
${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}
${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()
set(CMAKE_CXX_FLAGS "-Wall ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "-Werror ${CMAKE_CXX_FLAGS_DEBUG}")
# compilation flags for Mac OS X deployment
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND ${CMAKE_BUILD_TYPE} MATCHES "Release")
if(EXISTS /Developer/SDKs/MacOSX10.5.sdk)
set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.5.sdk" CACHE STRING "OS version whose headers you'll use" FORCE)
set(CMAKE_OSX_ARCHITECTURES "ppc;i386;x86_64;" CACHE STRING "Compile for these processor architecture" FORCE)
endif()
if(NOT $ENV{MACOSX_DEPLOYMENT_TARGET} EQUAL "")
set(CMAKE_OSX_DEPLOYMENT_TARGET "$ENV{MACOSX_DEPLOYMENT_TARGET}" CACHE STRING "The oldest OS version supported" FORCE)
if($ENV{MACOSX_DEPLOYMENT_TARGET} STRGREATER "10.4")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Xlinker -rpath -Xlinker @loader_path/../Frameworks/" CACHE STRING "Embed frameworks search path" FORCE)
endif()
if($ENV{MACOSX_DEPLOYMENT_TARGET} STRLESS "10.6")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -no_compact_linkedit" CACHE STRING "Disable 10.6+ features if deploy on older version" FORCE)
endif()
endif()
endif()
# solarus options
option(DEBUG_KEYS "Enable the debugging keys." OFF)
if(DEBUG_KEYS)
add_definitions(-DSOLARUS_DEBUG_KEYS)
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(DEFAULT_WRITE_DIR "Library/Application Support/Solarus")
else()
set(DEFAULT_WRITE_DIR ".solarus")
endif()
set(WRITE_DIR ${DEFAULT_WRITE_DIR} CACHE STRING "Directory where Solarus savegames are stored, relative to the user's home directory")
if(WRITE_DIR)
add_definitions(-DSOLARUS_WRITE_DIR=\"${WRITE_DIR}\")
endif()
if(PANDORA)
set(DEFAULT_SCREEN_WIDTH 400)
else()
set(DEFAULT_SCREEN_WIDTH 320)
endif()
set(SCREEN_WIDTH ${DEFAULT_SCREEN_WIDTH} CACHE INTEGER "Width of the logical screen in pixels")
set(SCREEN_HEIGHT 240 CACHE INTEGER "Height of the logical screen in pixels")
if(SCREEN_WIDTH)
add_definitions(-DSOLARUS_SCREEN_WIDTH=${SCREEN_WIDTH})
endif()
if(SCREEN_HEIGHT)
add_definitions(-DSOLARUS_SCREEN_HEIGHT=${SCREEN_HEIGHT})
endif()
if(PANDORA OR CAANOO)
set(DEFAULT_COLOR_DEPTH 16)
else()
set(DEFAULT_COLOR_DEPTH 32)
endif()
set(COLOR_DEPTH ${DEFAULT_COLOR_DEPTH} CACHE INTEGER "Number of bits per pixel for surfaces")
if(COLOR_DEPTH)
add_definitions(-DSOLARUS_COLOR_DEPTH=${COLOR_DEPTH})
endif()
# files to install with make install
install(TARGETS solarus
RUNTIME DESTINATION bin
)