forked from aseprite/aseprite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
313 lines (255 loc) · 10.7 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
# Aseprite
# Copyright (C) 2001-2015 David Capello
#
# Parts of this file come from the Allegro 4.4 CMakeLists.txt
# CMake setup
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
if(COMMAND cmake_policy)
# CMP0003: Libraries linked via full path no longer produce linker search paths.
#cmake_policy(SET CMP0003 NEW)
if(CMAKE_MAJOR_VERSION GREATER 2)
# CMP0046: Old behavior to silently ignore non-existent dependencies.
cmake_policy(SET CMP0046 OLD)
endif(CMAKE_MAJOR_VERSION GREATER 2)
endif(COMMAND cmake_policy)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
"Choose the type of build, options are:
None Debug Release RelWithDebInfo Profile."
FORCE)
endif()
# Restrict configuration types to the selected build type.
# Note: This needs to be done before the project command
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_BUILD_TYPE}" CACHE INTERNAL "internal")
# Aseprite project
project(aseprite C CXX)
######################################################################
# Options (these can be specified in cmake command line or modifying
# CMakeCache.txt)
option(USE_STATIC_LIBC "Use static version of C and C++ runtimes" off)
option(USE_SHARED_CURL "Use your installed copy of curl" off)
option(USE_SHARED_GIFLIB "Use your installed copy of giflib" off)
option(USE_SHARED_JPEGLIB "Use your installed copy of jpeglib" off)
option(USE_SHARED_ZLIB "Use your installed copy of zlib" off)
option(USE_SHARED_LIBPNG "Use your installed copy of libpng" off)
option(USE_SHARED_LIBLOADPNG "Use your installed copy of libloadpng" off)
option(USE_SHARED_TINYXML "Use your installed copy of tinyxml" off)
option(USE_SHARED_GTEST "Use your installed copy of gtest" off)
option(USE_SHARED_PIXMAN "Use your installed copy of pixman" off)
option(USE_SHARED_ALLEGRO4 "Use shared Allegro 4 library (without resize support)" off)
option(USE_ALLEG4_BACKEND "Use Allegro 4 backend" on)
option(USE_SKIA_BACKEND "Use Skia backend" off)
option(ENABLE_MEMLEAK "Enable memory-leaks detector (only for developers)" off)
option(ENABLE_UPDATER "Enable automatic check for updates" on)
option(ENABLE_WEBSERVER "Enable support to run a webserver (for HTML5 gamedev)" off)
option(ENABLE_TRIAL_MODE "Compile the trial version" off)
option(FULLSCREEN_PLATFORM "Enable fullscreen by default" off)
set(CUSTOM_WEBSITE_URL "" CACHE STRING "Enable custom local webserver to check updates")
######################################################################
# Profile build type
list(APPEND CMAKE_BUILD_TYPES Profile)
mark_as_advanced(
CMAKE_C_FLAGS_PROFILE
CMAKE_CXX_FLAGS_PROFILE
CMAKE_EXE_LINKER_FLAGS_PROFILE)
if(CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_C_FLAGS_PROFILE "-pg"
CACHE STRING "Profiling C flags")
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_C_FLAGS_PROFILE}"
CACHE STRING "Profiling C++ flags")
set(CMAKE_EXE_LINKER_FLAGS_PROFILE "-pg"
CACHE STRING "Profiling linker flags")
endif()
if(MSVC)
set(CMAKE_C_FLAGS_PROFILE "/MD /Zi /Ox /Gd /D NDEBUG"
CACHE STRING "Profiling C flags")
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_C_FLAGS_PROFILE}"
CACHE STRING "Profiling C++ flags")
set(CMAKE_EXE_LINKER_FLAGS_PROFILE "/PROFILE /DEBUG"
CACHE STRING "Profiling linker flags")
endif()
######################################################################
# Directories
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
# We need to specify the output for each configuration to make it work
# on Visual Studio solutions.
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_PROFILE "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_PROFILE "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_PROFILE "${CMAKE_BINARY_DIR}/bin")
set(CURL_DIR ${CMAKE_SOURCE_DIR}/third_party/curl)
set(GIFLIB_DIR ${CMAKE_SOURCE_DIR}/third_party/giflib)
set(LIBFREETYPE_DIR ${CMAKE_SOURCE_DIR}/third_party/freetype)
set(LIBJPEG_DIR ${CMAKE_SOURCE_DIR}/third_party/jpeg)
set(LIBPNG_DIR ${CMAKE_SOURCE_DIR}/third_party/libpng)
set(LOADPNG_DIR ${CMAKE_SOURCE_DIR}/third_party/loadpng)
set(MONGOOSE_DIR ${CMAKE_SOURCE_DIR}/third_party/mongoose)
set(PIXMAN_DIR ${CMAKE_SOURCE_DIR}/third_party/pixman)
set(SIMPLEINI_DIR ${CMAKE_SOURCE_DIR}/third_party/simpleini)
set(TINYXML_DIR ${CMAKE_SOURCE_DIR}/third_party/tinyxml)
set(ZLIB_DIR ${CMAKE_SOURCE_DIR}/third_party/zlib)
# Zlib generated zconf.h file
include_directories(${CMAKE_BINARY_DIR}/third_party/zlib)
# We need private libpng header files so it doesn't matter if we use
# the shared version of libpng or not, we need to find header files in
# "third_party/libpng"" directory.
include_directories(${LIBPNG_DIR})
# Search in the "cmake" directory for additional CMake modules.
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# Put libraries into "lib".
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
######################################################################
# Common definitions to compile all sources
# Do not use MMX optimizations in PNG code
add_definitions(-DPNG_NO_MMX_CODE)
# Debug C/C++ flags
if(CMAKE_BUILD_TYPE STREQUAL Debug)
add_definitions(-DDEBUGMODE -D_DEBUG)
else()
add_definitions(-DNDEBUG)
endif()
# Fix to compile gtest with VC11 (2012)
if(NOT USE_SHARED_GTEST)
if (MSVC_VERSION EQUAL 1700)
add_definitions(-D_VARIADIC_MAX=10)
endif()
endif()
if(NOT USE_SHARED_CURL)
set(CURL_STATICLIB ON BOOL)
endif()
######################################################################
# Allegro 4 backend
if(USE_ALLEG4_BACKEND)
if(USE_SHARED_ALLEGRO4)
# Find the shared Allegro 4 library
find_library(LIBALLEGRO4_LIBRARY alleg)
find_path(LIBALLEGRO4_INCLUDE_DIR allegro.h)
if(NOT LIBALLEGRO4_LIBRARY)
message(FATAL_ERROR "Allegro 4 not found")
endif()
# Get flags to link programs using allegro-config program
execute_process(COMMAND allegro-config --libs --shared
OUTPUT_VARIABLE LIBALLEGRO4_LINK_FLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(LIBALLEGRO4_LINK_FLAGS ${LIBALLEGRO4_LINK_FLAGS} ${PLATFORM_LIBS})
include_directories(${LIBALLEGRO4_INCLUDE_DIR})
else()
include_directories(${CMAKE_SOURCE_DIR}/src/allegro/include)
include_directories(${CMAKE_BINARY_DIR}/include)
add_definitions(-DALLEGRO4_WITH_RESIZE_PATCH)
add_definitions(-DALLEGRO4_WITH_EXTRA_CURSORS)
# Static Allegro (the code of Allegro library is embedded).
add_definitions(-DALLEGRO_STATICLINK)
endif()
endif()
######################################################################
# Platform specific stuff
set(PLATFORM_LIBS)
# -- Unix --
if(UNIX AND NOT APPLE AND NOT BEOS)
# Pthreads
find_package(Threads)
if(NOT CMAKE_USE_PTHREADS_INIT)
message(FATAL_ERROR "Unix port requires pthreads support.")
endif()
list(APPEND PLATFORM_LIBS m ${CMAKE_THREAD_LIBS_INIT})
# X11
find_package(X11)
if(NOT X11_FOUND)
message(FATAL_ERROR "Unix port requires X11 (e.g. libx11-dev).")
endif()
include_directories(SYSTEM ${X11_INCLUDE_DIR})
list(APPEND PLATFORM_LIBS ${X11_LIBRARIES})
if(X11_XShm_FOUND)
list(APPEND PLATFORM_LIBS ${X11_Xext_LIB})
endif()
if(X11_Xcursor_FOUND)
list(APPEND PLATFORM_LIBS ${X11_Xcursor_LIB})
endif()
if(X11_Xpm_FOUND)
list(APPEND PLATFORM_LIBS ${X11_Xpm_LIB})
endif()
find_library(X11_Xxf86vm_LIB Xxf86vm ${X11_LIB_SEARCH_PATH})
mark_as_advanced(X11_Xxf86vm_LIB)
if(X11_xf86vmode_FOUND)
list(APPEND PLATFORM_LIBS ${X11_Xxf86vm_LIB})
endif()
check_library_exists(X11 XOpenIM "${X11_LIB_SEARCH_PATH}" XIM_FOUND)
check_library_exists(Xxf86dga XDGAQueryExtension
"${X11_LIB_SEARCH_PATH}" XDGA_FOUND)
if(XDGA_FOUND)
list(APPEND PLATFORM_LIBS Xxf86dga ${X11_LIBRARIES})
endif()
endif()
# -- Windows --
if(WIN32)
if(USE_ALLEG4_BACKEND)
find_package(DXGuid)
if(NOT DXGUID_FOUND)
if(MSVC)
message(FATAL_ERROR "DirectX required for Windows port. You might need to add DirectX include and lib directories to your INCLUDE and LIB environment variables.")
else()
message(FATAL_ERROR "DirectX required for Windows port.")
endif()
endif()
include_directories(SYSTEM ${DXGUID_INCLUDE_DIR})
else()
set(DXGUID_LIBRARIES)
endif()
list(APPEND PLATFORM_LIBS
kernel32 user32 gdi32 comdlg32 ole32 winmm
shlwapi psapi wininet comctl32 dbghelp
${DXGUID_LIBRARIES})
# Windows XP is the minimum supported platform.
add_definitions(-D_WIN32_WINNT=0x0501 -DWINVER=0x0501)
# We need Unicode support
add_definitions(-DUNICODE -D_UNICODE)
endif(WIN32)
# -- Mac OS X --
if(APPLE)
find_library(COCOA_LIBRARY Cocoa)
find_library(CARBON_LIBRARY Carbon)
find_library(IOKIT_LIBRARY IOKit)
find_library(COREAUDIO_LIBRARY CoreAudio)
find_library(AUDIOUNIT_LIBRARY AudioUnit)
find_library(AUDIOTOOLBOX_LIBRARY AudioToolbox)
find_package(QuickTime)
mark_as_advanced(COCOA_LIBRARY CARBON_LIBRARY IOKIT_LIBRARY)
mark_as_advanced(COREAUDIO_LIBRARY AUDIOUNIT_LIBRARY AUDIOTOOLBOX_LIBRARY)
mark_as_advanced(QUICKTIME_INCLUDE_DIR QUICKTIME_LIBRARY)
list(APPEND PLATFORM_LIBS
${COCOA_LIBRARY}
${CARBON_LIBRARY}
${IOKIT_LIBRARY}
${COREAUDIO_LIBRARY}
${AUDIOUNIT_LIBRARY}
${AUDIOTOOLBOX_LIBRARY}
${QUICKTIME_LIBRARY})
# Hack to deal with Mac OS X 10.6. NSQuickDrawView is not defined by
# NSQuickDrawView.h when compiling in 64-bit mode, and 64-bit mode is the
# default when compiling on Snow Leopard.
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL i386)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch i386")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch i386")
endif()
# The Mac port simply uses too many deprecated things.
if(COMPILER_GCC)
set(WFLAGS "${WFLAGS} -Wno-deprecated-declarations")
endif(COMPILER_GCC)
endif(APPLE)
######################################################################
# Main ASE targets
add_subdirectory(src)
######################################################################
# Third party libraries
add_subdirectory(third_party)