-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCMakeLists.txt
267 lines (235 loc) · 6.62 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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
project(monster-rpg-2)
cmake_minimum_required(VERSION 2.6)
OPTION(KCM_AUDIO "Use Allegro audio instead of BASS" off)
OPTION(WITH_SVG "Enable SVG loader" off)
OPTION(RASPBERRYPI "Compile for Raspberry Pi" off)
OPTION(DEMO "Build demo version" off)
OPTION(STEAMWORKS "Enable Steamworks" off)
set(ALLEGRO_SUFFIX "-static" CACHE STRING "Allegro library suffix")
# function to copy files to build dir:
function(copy_file_to_build target file dest)
add_custom_target(${target} ALL DEPENDS ${dest})
add_custom_command(
OUTPUT ${dest}
COMMAND "${CMAKE_COMMAND}" -E copy
"${CMAKE_CURRENT_SOURCE_DIR}/${file}" ${dest}
)
endfunction(copy_file_to_build)
# Option configuration
if(WIN32)
set(M2_SUFFIX "")
else(WIN32)
if(RASPBERRYPI)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Os -march=armv6 -mfpu=vfp -mfloat-abi=hard")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Os -march=armv6 -mfpu=vfp -mfloat-abi=hard")
include_directories(
"/opt/vc/include"
"/opt/vc/include/interface/vcos/pthreads"
"/opt/vc/include/interface/vmcs_host/linux"
)
link_directories(
"/opt/vc/lib"
)
else()
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
endif()
if(STEAMWORKS)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DSTEAMWORKS")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DSTEAMWORKS")
endif()
endif()
include_directories("${CMAKE_SOURCE_DIR}/include")
if(NOT ("${USER_INCLUDE_PATH}" STREQUAL ""))
include_directories(${USER_INCLUDE_PATH})
endif()
if(NOT ("${USER_LIBRARY_PATH}" STREQUAL ""))
link_directories(${USER_LIBRARY_PATH})
endif()
set(COMMON_SOURCES
src/3d.cpp
src/Animation.cpp
src/AnimationSet.cpp
src/Area.cpp
src/CombatActions.cpp
src/CombatEnemy.cpp
src/CombatEntity.cpp
src/CombatPlayer.cpp
src/Combatant.cpp
src/Configuration.cpp
src/Frame.cpp
src/GenericEffect.cpp
src/Image.cpp
src/Input.cpp
src/Items.cpp
src/Object.cpp
src/Player.cpp
src/Spells.cpp
src/Tile.cpp
src/atlas.cpp
src/atlas_accessor.cpp
src/battle.cpp
src/debug.cpp
src/equipment.cpp
src/graphics.cpp
src/inventory.cpp
src/io.cpp
src/lander.cpp
src/my_load_bitmap.cpp
src/pause.cpp
src/redundant.cpp
src/script.cpp
src/shooter.cpp
src/sound.cpp
src/tgui.cpp
src/translate.cpp
src/util.cpp
src/widgets.cpp
src/xml.cpp
)
if(APPLE)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNO_GAMECENTER")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNO_GAMECENTER")
set(COMMON_SOURCES ${COMMON_SOURCES} src/init.mm src/gamecenter.mm)
else()
set(COMMON_SOURCES ${COMMON_SOURCES} src/init.cpp)
endif()
set(EXTRA_LIBS "")
if(WITH_SVG)
list(APPEND EXTRA_LIBS "allegro_color${ALLEGRO_SUFFIX}" "svgtiny" "hubbub" "dom" "parserutils" "wapcaplet" "expat")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DWITH_SVG -I/opt/netsurf/include")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DWITH_SVG -I/opt/netsurf/include")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/opt/netsurf/lib")
set(COMMON_SOURCES ${COMMON_SOURCES} src/svg.cpp)
endif()
add_library(mo2-engine STATIC ${COMMON_SOURCES})
if(DEMO)
set(EXENAME MonsterRPG2Demo${M2_SUFFIX})
else()
set(EXENAME MonsterRPG2${M2_SUFFIX})
endif()
set(EXE_SOURCES src/monster2.cpp)
if(WIN32)
list(APPEND EXE_SOURCES icons/windows_icon.rc)
endif()
add_executable(${EXENAME} ${EXE_SOURCES})
if(KCM_AUDIO)
if(NOT WIN32)
LIST(APPEND EXTRA_LIBS "asound" "pulse-simple" "pulse" "vorbisfile" "vorbis" "ogg")
endif()
endif()
if(WIN32)
set(CFLAGS "/MT /MP /D_USE_MATH_DEFINES /DALLEGRO_STATICLINK /EHsc /D_WIN32_WINNT=0x501")
if(KCM_AUDIO)
set(CFLAGS "/DKCM_AUDIO")
endif()
if(DEMO)
set(CFLAGS "${CFLAGS} /DDEMO")
endif()
if(STEAMWORKS)
set(CFLAGS "${CFLAGS} /DSTEAMWORKS")
endif()
set_target_properties(mo2-engine PROPERTIES COMPILE_FLAGS "${CFLAGS}")
set_target_properties(${EXENAME} PROPERTIES COMPILE_FLAGS "${CFLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO /SUBSYSTEM:WINDOWS")
list(APPEND EXTRA_LIBS
"dxguid"
"dinput8"
"dsound"
"d3d9"
"d3dx9"
"opengl32"
"comdlg32"
"gdi32"
"gdiplus"
"kernel32"
"ole32"
"psapi"
"shlwapi"
"user32"
"uuid"
"winmm"
"lua5.2"
"freetype"
"physfs"
"zlibstatic"
"allegro_monolith-static"
)
if(STEAMWORKS)
list(APPEND EXTRA_LIBS "steam_api")
endif()
SET(MAIN_LIBS
${ICON_OBJ}
mo2-engine
${EXTRA_LIBS}
)
if(KCM_AUDIO)
LIST(APPEND MAIN_LIBS "ws2_32" "dsound")
else()
LIST(APPEND MAIN_LIBS "bass")
endif(KCM_AUDIO)
else(WIN32)
if(KCM_AUDIO)
set(CMAKE_C_FLAGS_RELEASE "-DKCM_AUDIO")
set(CMAKE_CXX_FLAGS_RELEASE "-DKCM_AUDIO")
endif()
if(DEMO)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DDEMO")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DDEMO")
endif()
if(APPLE)
set(ALLEGRO_MAIN_LIB "allegro_main${ALLEGRO_SUFFIX}")
FIND_LIBRARY(OPENGL_LIBRARY OpenGL)
FIND_LIBRARY(FOUNDATION_LIBRARY Foundation)
FIND_LIBRARY(APPSERVICES_LIBRARY ApplicationServices)
FIND_LIBRARY(APPKIT_LIBRARY AppKit)
FIND_LIBRARY(IOKIT_LIBRARY IOKit)
FIND_LIBRARY(AUDIOTOOLBOX_LIBRARY AudioToolbox)
FIND_LIBRARY(SECURITY_LIBRARY Security)
LIST(APPEND EXTRA_LIBS ${IOKIT_LIBRARY} ${OPENGL_LIBRARY} ${FOUNDATION_LIBRARY} ${APPSERVICES_LIBRARY} ${APPKIT_LIBRARY} ${AUDIOTOOLBOX_LIBRARY} ${GAMEKIT_LIBRARY} ${SECURITY_LIBRARY})
SET(MAIN_LIBS
mo2-engine
allegro_ttf${ALLEGRO_SUFFIX}
allegro_font${ALLEGRO_SUFFIX}
allegro_primitives${ALLEGRO_SUFFIX}
allegro_dialog${ALLEGRO_SUFFIX}
allegro_memfile${ALLEGRO_SUFFIX}
allegro_image${ALLEGRO_SUFFIX}
allegro_physfs${ALLEGRO_SUFFIX}
allegro${ALLEGRO_SUFFIX} ${ALLEGRO_MAIN_LIB}
${EXTRA_LIBS}
/Users/trent/code/local/lib/libfreetype.a
/Users/trent/code/local/lib/libphysfs.a
/Users/trent/code/local/lib/libz.a
/Users/trent/code/local/lib/liblua.a
)
if(KCM_AUDIO)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework OpenAL")
else()
LIST(APPEND MAIN_LIBS "bass")
endif()
else()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,\$ORIGIN")
SET(MAIN_LIBS
mo2-engine
allegro_monolith${ALLEGRO_SUFFIX}
${EXTRA_LIBS}
Xcursor Xi Xinerama Xrandr SM ICE X11 Xext
)
if(NOT KCM_AUDIO)
LIST(APPEND MAIN_LIBS "${CMAKE_BINARY_DIR}/libbass.so")
endif()
if(STEAMWORKS)
LIST(APPEND MAIN_LIBS "${CMAKE_BINARY_DIR}/libsteam_api.so")
endif()
if(RASPBERRYPI)
LIST(APPEND MAIN_LIBS GLESv2 EGL bcm_host m pthread freetype physfs png z lua5.2)
else()
LIST(APPEND MAIN_LIBS GL GLU physfs freetype z png lua5.2 pthread)
endif()
endif()
endif()
target_link_libraries(
${EXENAME}
${MAIN_LIBS}
)