forked from kazzmir/paintown
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
329 lines (275 loc) · 14.9 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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
# -------------------------------------------------------
# Paintown cmake build script. Creates makefiles for unix
# based systems, cygwin(sp?) or mingw
#
# Written by: juvinious
# Modified: 06/27/2009
# -------------------------------------------------------
# -------------------------------------------------------
# Ensure that we are doing an out of source build
# Prevents any mishaps
# Also remove the makefile to regenerate the filelist
# -------------------------------------------------------
cmake_minimum_required(VERSION 2.6)
if(EXISTS ${CMAKE_SOURCE_DIR}/CMakeCache.txt)
file(REMOVE ${CMAKE_SOURCE_DIR}/CMakeCache.txt)
file(REMOVE_RECURSE ${CMAKE_SOURCE_DIR}/CMakeFiles)
endif(EXISTS ${CMAKE_SOURCE_DIR}/CMakeCache.txt)
if(EXISTS ${CMAKE_BINARY_DIR}/Makefile)
file(REMOVE ${CMAKE_BINARY_DIR}/Makefile)
endif(EXISTS ${CMAKE_BINARY_DIR}/Makefile)
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
if(UNIX AND NOT CYGWIN)
message(FATAL_ERROR "Oops. Don't do an in-source build. Create an extra directory change into it and run cmake pointing to the base directory. IE: \nmkdir mybuild && cd mybuild && cmake ../ && make\nYou may need to remove CMakeCache.txt and the CMakeFiles directory in ${CMAKE_SOURCE_DIR} if you can't get rid of this error.")
else(UNIX AND NOT CYGWIN)
message(FATAL_ERROR "Oops. Don't do an in-source build. Create an extra directory change into it and run cmake pointing to the base directory. IE: \nmkdir mybuild; cd mybuild; cmakesetup ../\nYou may need to remove CMakeCache.txt and the CMakeFiles directory in ${CMAKE_SOURCE_DIR} if you can't get rid of this error.")
endif(UNIX AND NOT CYGWIN)
endif(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
# -------------------------------------------------------
# Directory in which extra macros can be found
# -------------------------------------------------------
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
# -------------------------------------------------------
# Directory in which extra macros can be found
# -------------------------------------------------------
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
# -------------------------------------------------------
# Add in uninstall target
# -------------------------------------------------------
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
# -------------------------------------------------------
# project name
# -------------------------------------------------------
project (paintown)
# -------------------------------------------------------
# Including needed macros
# -------------------------------------------------------
include(CheckCSourceCompiles)
include(CheckCXXSourceCompiles)
find_package(ZLIB)
find_package(PNG)
find_package(FREETYPE)
find_package(Threads)
#find_package(GNUREGEX)
find_package(VORBIS)
find_package(OGG)
find_package(MPG123)
# -------------------------------------------------------
# Include Source
# -------------------------------------------------------
include(FileList)
mark_as_advanced(CLEAR ZLIB_INCLUDE_DIR)
mark_as_advanced(CLEAR ZLIB_LIBRARY)
mark_as_advanced(CLEAR PNG_PNG_INCLUDE_DIR)
mark_as_advanced(CLEAR PNG_LIBRARY)
# -------------------------------------------------------
# User setable options
# -------------------------------------------------------
option(DEBUG "Compile paintown with debug information?" OFF)
if($ENV{DEBUG})
set(DEBUG ON)
elseif(NOT $ENV{DEBUG})
set(DEBUG OFF)
endif($ENV{DEBUG})
if(DEBUG)
add_definitions(-DDEBUG)
set(CMAKE_CXX_FLAGS "-Wall -Wno-unused-variable -Wno-unused-function -funroll-loops -fexpensive-optimizations -Woverloaded-virtual -g3 -ggdb")
set(CMAKE_C_FLAGS "-Wall -Wno-unused-variable -Wno-unused-function -funroll-loops -fexpensive-optimizations -g3 -ggdb")
else(DEBUG)
set(CMAKE_CXX_FLAGS "-O2 -Wall -Wno-unused-variable -Wno-unused-function -funroll-loops -fexpensive-optimizations -Woverloaded-virtual")
set(CMAKE_C_FLAGS "-O2 -Wall -Wno-unused-variable -Wno-unused-function -funroll-loops -fexpensive-optimizations")
endif(DEBUG)
# FIXME: not sure if this is in the right place
add_definitions(-DHAVE_NETWORKING)
option(USE_SDL "Compile paintown with SDL instead of Allegro?" ON)
option(USE_ALLEGRO5 "Compile paintown with ALLEGRO 5 instead of SDL or Allegro 4.x?" OFF)
if($ENV{ALLEGRO5})
set(USE_ALLEGRO5 ON)
set(USE_SDL OFF)
elseif(NOT $ENV{ALLEGRO5})
set(USE_ALLEGRO5 OFF)
endif($ENV{ALLEGRO5})
if($ENV{SDL})
set(USE_SDL ON)
elseif(NOT $ENV{SDL})
set(USE_SDL OFF)
endif($ENV{SDL})
if(OGG_FOUND)
add_definitions(-DHAVE_OGG)
set(OGG_LIBS ${OGG_LIBRARY} ${VORBIS_LIBRARIES})
set(OGG_INCLUDES ${OGG_INCLUDE_DIR} ${VORBIS_INCLUDE_DIR})
else(OGG_FOUND)
set(OGG_LIBS "")
set(OGG_INCLUDES "")
endif(OGG_FOUND)
if(USE_SDL)
# packages
find_package(SDL)
# sdl
add_definitions(-DUSE_SDL)
if(NOT SDL_FOUND)
message(FATAL_ERROR "Couldn't find SDL.")
endif(NOT SDL_FOUND)
# SET Mixer definition
if (MAD_FOUND)
add_definitions(-DMP3_MAD_MUSIC)
endif(MAD_FOUND)
set(GRAPHICS_LIBRARIES sfl_module sprig_module sdl_stretch_module image_module mixer_module ${SDL_LIBRARY})
set(GRAPHICS_INCLUDES ${SDL_INCLUDE_DIR})
if (APPLE)
add_definitions(-DUSE_SDL_MAIN)
endif(APPLE)
elseif(USE_ALLEGRO5)
find_package(ALLEGRO5)
if(NOT ALLEGRO_FOUND)
message(FATAL_ERROR "Couldn't find Allegro 5 and/or a required Allegro 5 module")
endif(NOT ALLEGRO_FOUND)
set(GRAPHICS_LIBRARIES sfl_module ${ALLEGRO_LIBRARIES})
set(GRAPHICS_INCLUDES ${ALLEGRO_INCLUDE_DIR})
else(USE_SDL)
#packages
find_package(ALLEGRO)
if(NOT ALLEGRO_FOUND)
message(FATAL_ERROR "Couldn't find Allegro")
endif(NOT ALLEGRO_FOUND)
add_library(algif_module src/util/allegro/gif/algif.c src/util/allegro/gif/gif.c src/util/allegro/gif/lzw.c)
set(GRAPHICS_LIBRARIES ${ALLEGRO_LIBRARIES} algif_module)
endif(USE_SDL)
if(MPG123_FOUND)
add_definitions(-DHAVE_MP3_MPG123)
set(MP3_LIBS ${MPG123_LIBRARY})
set(MP3_INCLUDES ${MPG123_INCLUDE_DIR})
else(MPG123_FOUND)
if (SDL_FOUND)
# Try looking for libmad instead only if SDL is available
find_package(MAD)
if (MAD_FOUND)
add_definitions(-DHAVE_MP3_MAD)
set(MP3_LIBS ${MAD_LIBRARY})
set(MP3_INCLUDES ${MAD_INCLUDE_DIR})
else(MAD_FOUND)
set(MP3_LIBS "")
set(MP3_INCLUDES "")
endif(MAD_FOUND)
endif (SDL_FOUND)
endif(MPG123_FOUND)
# freetype
if(NOT FREETYPE_FOUND)
message(FATAL_ERROR "Couldn't find freetype")
endif(NOT FREETYPE_FOUND)
# regex
#if(NOT GNUREGEX_FOUND)
# message(FATAL_ERROR "Couldn't find GNU Regex")
#endif(NOT GNUREGEX_FOUND)
# -------------------------------------------------------
# Paths and system setup
# -------------------------------------------------------
# -------------------------------------------------------
# MINGW
# -------------------------------------------------------
if(MINGW OR CYGWIN)
# -------------------------------------------------------
# Take those user options and set the necessary compile time preprocessors
# -------------------------------------------------------
add_definitions(-DWINDOWS)
set(WIN_LIB -lgdi32 -luser32 -lwsock32)
set(CMAKE_THREAD_LIBS_INIT -lpthreadGC2)
else(MINGW OR CYGWIN)
set(CMAKE_THREAD_LIBS_INIT -lpthread)
endif(MINGW OR CYGWIN)
# -------------------------------------------------------
# Apple OSX
# -------------------------------------------------------
if(APPLE)
# -------------------------------------------------------
# Added stuff for osx
# -------------------------------------------------------
set(WIN_LIB "-framework Carbon")
add_definitions(-DMACOSX)
# Groups
set(GROUP_START "-Wl,-all_load")
set(GROUP_END "")
else(APPLE)
# Groups
set(GROUP_START "-Wl,--start-group")
set(GROUP_END "-Wl,--end-group")
endif(APPLE)
# -------------------------------------------------------
# Include directory
# -------------------------------------------------------
include_directories(src src/util/network/hawknl ${GRAPHICS_INCLUDES} ${FREETYPE_INCLUDE_DIR} ${OGG_INCLUDES} ${MP3_INCLUDES})
# -------------------------------------------------------
# Put the linked libraries together
# -------------------------------------------------------
set(REQUIRED_LIBS ${GRAPHICS_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${FREETYPE_LIBRARIES} ${PNG_LIBRARY} ${ZLIB_LIBRARY} ${OGG_LIBS} ${MP3_LIBS} ${WIN_LIB} ${WINSOCK})
# -------------------------------------------------------
# Paintown and test
# -------------------------------------------------------
#add_library (main_module ${ALL_SRC})
add_subdirectory(${CMAKE_SOURCE_DIR}/src/util/7z)
#Dumb
add_subdirectory(${CMAKE_SOURCE_DIR}/src/util/sound/dumb)
#Util
add_subdirectory(${CMAKE_SOURCE_DIR}/src/util)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/mugen)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/paintown-engine)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/platformer)
#Hawknl
add_subdirectory(${CMAKE_SOURCE_DIR}/src/util/network/hawknl)
#Minizip
add_subdirectory(${CMAKE_SOURCE_DIR}/src/util/zip)
#Source modules
add_library(base_module ${BASE_SRC})
add_library(factory_module ${FACTORY_SRC})
add_library(openbor_module ${OPENBOR_SRC})
# add_library(util_module ${UTIL_SRC})
# add_library(loadpng_module ${LOADPNG_SRC})
# add_library(menu_module ${MENU_SRC})
# add_library(gui_module ${GUI_SRC})
# add_library(algif_module src/util/gif/algif.c src/util/gif/gif.c src/util/gif/lzw.c)
# GME Library
add_library(gme_module src/util/sound/gme/Ay_Apu.cpp src/util/sound/gme/Ay_Cpu.cpp src/util/sound/gme/Ay_Emu.cpp src/util/sound/gme/Blip_Buffer.cpp src/util/sound/gme/Classic_Emu.cpp src/util/sound/gme/Data_Reader.cpp src/util/sound/gme/Dual_Resampler.cpp src/util/sound/gme/Effects_Buffer.cpp src/util/sound/gme/Fir_Resampler.cpp src/util/sound/gme/Gb_Apu.cpp src/util/sound/gme/Gb_Cpu.cpp src/util/sound/gme/Gb_Oscs.cpp src/util/sound/gme/Gbs_Emu.cpp src/util/sound/gme/gme.cpp src/util/sound/gme/Gme_File.cpp src/util/sound/gme/Gym_Emu.cpp src/util/sound/gme/Hes_Apu.cpp src/util/sound/gme/Hes_Cpu.cpp src/util/sound/gme/Hes_Emu.cpp src/util/sound/gme/Kss_Cpu.cpp src/util/sound/gme/Kss_Emu.cpp src/util/sound/gme/Kss_Scc_Apu.cpp src/util/sound/gme/M3u_Playlist.cpp src/util/sound/gme/Multi_Buffer.cpp src/util/sound/gme/Music_Emu.cpp src/util/sound/gme/Nes_Apu.cpp src/util/sound/gme/Nes_Cpu.cpp src/util/sound/gme/Nes_Fme7_Apu.cpp src/util/sound/gme/Nes_Namco_Apu.cpp src/util/sound/gme/Nes_Oscs.cpp src/util/sound/gme/Nes_Vrc6_Apu.cpp src/util/sound/gme/Nsfe_Emu.cpp src/util/sound/gme/Nsf_Emu.cpp src/util/sound/gme/Sap_Apu.cpp src/util/sound/gme/Sap_Cpu.cpp src/util/sound/gme/Sap_Emu.cpp src/util/sound/gme/Sms_Apu.cpp src/util/sound/gme/Snes_Spc.cpp src/util/sound/gme/Spc_Cpu.cpp src/util/sound/gme/Spc_Dsp.cpp src/util/sound/gme/Spc_Emu.cpp src/util/sound/gme/Vgm_Emu.cpp src/util/sound/gme/Vgm_Emu_Impl.cpp src/util/sound/gme/Ym2413_Emu.cpp src/util/sound/gme/Ym2612_Emu.cpp)
#Script directory
# add_subdirectory(${CMAKE_SOURCE_DIR}/src/paintown-engine/script)
# add_library(mugen_module ${MUGEN_SRC})
add_library(pcre_module src/util/pcre/pcre_chartables.c src/util/pcre/pcre_compile.c src/util/pcre/pcre_config.c src/util/pcre/pcre_dfa_exec.c src/util/pcre/pcre_exec.c src/util/pcre/pcre_fullinfo.c src/util/pcre/pcre_get.c src/util/pcre/pcre_globals.c src/util/pcre/pcre_info.c src/util/pcre/pcre_maketables.c src/util/pcre/pcre_newline.c src/util/pcre/pcre_ord2utf8.c src/util/pcre/pcreposix.c src/util/pcre/pcre_refcount.c src/util/pcre/pcre_study.c src/util/pcre/pcre_tables.c src/util/pcre/pcre_try_flipped.c src/util/pcre/pcre_ucd.c src/util/pcre/pcre_valid_utf8.c src/util/pcre/pcre_version.c src/util/pcre/pcre_xclass.c)
if (USE_SDL)
# IMAGE
add_subdirectory(${CMAKE_SOURCE_DIR}/src/util/graphics/sdl/image)
# SFL
add_subdirectory(${CMAKE_SOURCE_DIR}/src/util/sfl)
# Stretch
add_subdirectory(${CMAKE_SOURCE_DIR}/src/util/graphics/sdl/stretch)
# SPRIG
add_library(sprig_module src/util/graphics/sdl/sprig/SPG_extended.c src/util/graphics/sdl/sprig/SPG_primitives.c src/util/graphics/sdl/sprig/SPG_misc.c src/util/graphics/sdl/sprig/SPG_rotation.c src/util/graphics/sdl/sprig/SPG_polygon.c src/util/graphics/sdl/sprig/SPG_surface.c)
# Mixer
add_subdirectory(${CMAKE_SOURCE_DIR}/src/util/sound/sdl/mixer)
# add_library(mixer_module src/util/sound/sdl/mixer/music.c src/util/sound/sdl/mixer/mixer.c src/util/sound/sdl/mixer/music_ogg.c src/util/sound/sdl/mixer/music_flac.c src/util/sound/sdl/mixer/music_mad.c src/util/sound/sdl/mixer/dynamic_ogg.c src/util/sound/sdl/mixer/effect_position.c src/util/sound/sdl/mixer/effects_internal.c src/util/sound/sdl/mixer/effect_stereoreverse.c src/util/sound/sdl/mixer/load_voc.c src/util/sound/sdl/mixer/load_aiff.c src/util/sound/sdl/mixer/wavestream.c src/util/sound/sdl/mixer/load_ogg.c src/util/sound/sdl/mixer/convert.cpp)
elseif (USE_ALLEGRO5)
# SFL
add_subdirectory(${CMAKE_SOURCE_DIR}/src/util/sfl)
endif (USE_SDL)
#paintown executable
# add_executable (paintown src/util/xmain.cpp)
# set_target_properties(paintown PROPERTIES LINK_FLAGS "-Wl,--wrap=open -Wl,--wrap=read -Wl,--wrap=close -Wl,--wrap=lseek -Wl,--wrap=lstat -Wl,--wrap=access")
target_link_libraries(paintown ${GROUP_START} base_module paintown_module script_module openbor_module factory_module loadpng_module mugen_module platformer_module platformer_script_module util_module pcre_module x7z_module dumb_module minizip_module hawknl_module gme_module ${GROUP_END} ${REQUIRED_LIBS})
#add_executable (test src/test.cpp)
#target_link_libraries(test main_module dumb_module hawknl_module ${REQUIRED_LIBS})
#add_executable (menutest src/menu/menutest.cpp)
#target_link_libraries(menutest main_module dumb_module hawknl_module ${REQUIRED_LIBS})
#if (NOT USE_SDL)
# add_executable (mugentest src/mugen/test.cpp)
# target_link_libraries(mugentest ${GROUP_START} base_module level_module factory_module object_module util_module loadpng_module
# menu_module env_module network_module gui_module script_module game_module mugen_module ogg_module trigger_module pcre_module dumb_module hawknl_module gme_module ${GROUP_END} ${REQUIRED_LIBS})
#endif (NOT USE_SDL)
# Copy scripts and setup lex files
if(UNIX OR LINUX OR CYGWIN OR MINGW)
configure_file(${CMAKE_SOURCE_DIR}/src/paintown-engine/script/modules/paintown.py ${CMAKE_SOURCE_DIR}/data/scripts/paintown.py COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/src/paintown-engine/script/modules/paintown.rb ${CMAKE_SOURCE_DIR}/data/scripts/paintown.rb COPYONLY)
endif(UNIX OR LINUX OR CYGWIN OR MINGW)