2014-07-13 16:24:57 +00:00
# Aseprite
2015-03-16 18:05:13 +00:00
# Copyright (C) 2001-2015 David Capello
2012-01-05 22:45:03 +00:00
#
2010-10-16 20:02:12 +00:00
# Parts of this file come from the Allegro 4.4 CMakeLists.txt
# CMake setup
cmake_minimum_required ( VERSION 2.6 FATAL_ERROR )
2014-07-13 16:24:57 +00:00
if ( COMMAND cmake_policy )
# CMP0003: Libraries linked via full path no longer produce linker search paths.
#cmake_policy(SET CMP0003 NEW)
2014-09-14 09:00:05 +00:00
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 )
2014-07-13 16:24:57 +00:00
endif ( COMMAND cmake_policy )
2010-10-16 20:02:12 +00:00
if ( NOT CMAKE_BUILD_TYPE )
set ( CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
" C h o o s e t h e t y p e o f b u i l d , o p t i o n s a r e :
N o n e D e b u g R e l e a s e R e l W i t h D e b I n f o P r o f i l e . "
F O R C E )
endif ( )
2010-08-11 00:49:32 +00:00
2010-10-16 20:02:12 +00:00
# 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" )
2010-08-25 19:20:30 +00:00
2014-12-02 04:38:38 +00:00
# Aseprite project
2010-10-16 20:02:12 +00:00
project ( aseprite C CXX )
2010-08-11 00:49:32 +00:00
2010-08-25 19:20:30 +00:00
######################################################################
2011-07-28 00:26:22 +00:00
# Options (these can be specified in cmake command line or modifying
# CMakeCache.txt)
2010-08-25 19:20:30 +00:00
2010-09-30 20:04:32 +00:00
option ( USE_STATIC_LIBC "Use static version of C and C++ runtimes" off )
2012-03-15 03:17:49 +00:00
option ( USE_SHARED_CURL "Use your installed copy of curl" off )
option ( USE_SHARED_GIFLIB "Use your installed copy of giflib" off )
2010-09-30 20:04:32 +00:00
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 )
2012-07-09 00:21:01 +00:00
option ( USE_SHARED_LIBLOADPNG "Use your installed copy of libloadpng" off )
2012-03-19 17:04:24 +00:00
option ( USE_SHARED_TINYXML "Use your installed copy of tinyxml" off )
2012-03-19 17:33:49 +00:00
option ( USE_SHARED_GTEST "Use your installed copy of gtest" off )
2014-10-26 01:22:58 +00:00
option ( USE_SHARED_PIXMAN "Use your installed copy of pixman" off )
2012-03-19 16:24:15 +00:00
option ( USE_SHARED_ALLEGRO4 "Use shared Allegro 4 library (without resize support)" off )
2015-03-16 18:05:13 +00:00
option ( USE_ALLEG4_BACKEND "Use Allegro 4 backend" on )
option ( USE_SKIA_BACKEND "Use Skia backend" off )
2010-10-10 19:47:01 +00:00
option ( ENABLE_MEMLEAK "Enable memory-leaks detector (only for developers)" off )
2011-08-09 23:13:22 +00:00
option ( ENABLE_UPDATER "Enable automatic check for updates" on )
2013-03-31 03:36:00 +00:00
option ( ENABLE_WEBSERVER "Enable support to run a webserver (for HTML5 gamedev)" off )
2014-04-10 03:33:28 +00:00
option ( ENABLE_TRIAL_MODE "Compile the trial version" off )
2011-08-09 23:27:12 +00:00
option ( FULLSCREEN_PLATFORM "Enable fullscreen by default" off )
2014-06-03 00:31:44 +00:00
set ( CUSTOM_WEBSITE_URL "" CACHE STRING "Enable custom local webserver to check updates" )
2010-08-25 19:20:30 +00:00
######################################################################
2010-10-16 20:02:12 +00:00
# Profile build type
list ( APPEND CMAKE_BUILD_TYPES Profile )
mark_as_advanced (
C M A K E _ C _ F L A G S _ P R O F I L E
C M A K E _ C X X _ F L A G S _ P R O F I L E
2015-03-16 18:05:13 +00:00
C M A K E _ E X E _ L I N K E R _ F L A G S _ P R O F I L E )
2010-10-16 20:02:12 +00:00
2014-11-29 02:04:14 +00:00
if ( CMAKE_COMPILER_IS_GNUCC )
2010-10-16 20:02:12 +00:00
set ( CMAKE_C_FLAGS_PROFILE "-pg"
2014-11-29 02:04:14 +00:00
C A C H E S T R I N G " P r o f i l i n g C f l a g s " )
2010-10-16 20:02:12 +00:00
set ( CMAKE_CXX_FLAGS_PROFILE "${CMAKE_C_FLAGS_PROFILE}"
2014-11-29 02:04:14 +00:00
C A C H E S T R I N G " P r o f i l i n g C + + f l a g s " )
2010-10-16 20:02:12 +00:00
set ( CMAKE_EXE_LINKER_FLAGS_PROFILE "-pg"
2014-11-29 02:04:14 +00:00
C A C H E S T R I N G " P r o f i l i n g l i n k e r f l a g s " )
endif ( )
2010-10-16 20:02:12 +00:00
2014-11-29 02:04:14 +00:00
if ( MSVC )
set ( CMAKE_C_FLAGS_PROFILE "/MD /Zi /Ox /Gd /D NDEBUG"
C A C H E S T R I N G " P r o f i l i n g C f l a g s " )
2010-10-16 20:02:12 +00:00
set ( CMAKE_CXX_FLAGS_PROFILE "${CMAKE_C_FLAGS_PROFILE}"
2014-11-29 02:04:14 +00:00
C A C H E S T R I N G " P r o f i l i n g C + + f l a g s " )
set ( CMAKE_EXE_LINKER_FLAGS_PROFILE "/PROFILE /DEBUG"
C A C H E S T R I N G " P r o f i l i n g l i n k e r f l a g s " )
endif ( )
2010-10-16 20:02:12 +00:00
######################################################################
# Directories
2010-08-25 19:20:30 +00:00
2014-12-02 04:30:01 +00:00
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" )
2012-01-05 22:45:03 +00:00
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 )
2013-03-31 03:36:00 +00:00
set ( MONGOOSE_DIR ${ CMAKE_SOURCE_DIR } /third_party/mongoose )
2014-10-26 01:22:58 +00:00
set ( PIXMAN_DIR ${ CMAKE_SOURCE_DIR } /third_party/pixman )
2014-10-17 00:27:25 +00:00
set ( SIMPLEINI_DIR ${ CMAKE_SOURCE_DIR } /third_party/simpleini )
2012-01-05 22:45:03 +00:00
set ( TINYXML_DIR ${ CMAKE_SOURCE_DIR } /third_party/tinyxml )
set ( ZLIB_DIR ${ CMAKE_SOURCE_DIR } /third_party/zlib )
2010-08-11 00:49:32 +00:00
2012-01-08 00:32:53 +00:00
# Zlib generated zconf.h file
include_directories ( ${ CMAKE_BINARY_DIR } /third_party/zlib )
2012-03-19 17:27:00 +00:00
# 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 } )
2010-10-16 20:02:12 +00:00
# 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 )
2010-08-25 19:20:30 +00:00
######################################################################
# 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 ( )
2012-10-31 00:08:33 +00:00
# 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 ( )
2015-04-27 15:23:54 +00:00
if ( NOT USE_SHARED_CURL )
set ( CURL_STATICLIB ON BOOL )
endif ( )
2015-03-16 18:05:13 +00:00
######################################################################
# 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
O U T P U T _ V A R I A B L E L I B A L L E G R O 4 _ L I N K _ F L A G S
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
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 ( )
2010-10-16 20:02:12 +00:00
######################################################################
# 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
" $ { X 1 1 _ L I B _ S E A R C H _ P A T H } " X D G A _ F O U N D )
if ( XDGA_FOUND )
2011-03-06 19:20:11 +00:00
list ( APPEND PLATFORM_LIBS Xxf86dga ${ X11_LIBRARIES } )
2010-10-16 20:02:12 +00:00
endif ( )
endif ( )
# -- Windows --
if ( WIN32 )
2015-03-16 18:05:13 +00:00
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 ( )
2010-10-16 20:02:12 +00:00
endif ( )
2015-03-16 18:05:13 +00:00
include_directories ( SYSTEM ${ DXGUID_INCLUDE_DIR } )
else ( )
set ( DXGUID_LIBRARIES )
endif ( )
2010-10-16 20:02:12 +00:00
list ( APPEND PLATFORM_LIBS
2015-03-16 18:05:13 +00:00
k e r n e l 3 2 u s e r 3 2 g d i 3 2 c o m d l g 3 2 o l e 3 2 w i n m m
s h l w a p i p s a p i w i n i n e t c o m c t l 3 2 d b g h e l p
$ { D X G U I D _ L I B R A R I E S } )
2010-10-16 20:02:12 +00:00
2012-03-17 01:22:56 +00:00
# Windows XP is the minimum supported platform.
add_definitions ( -D_WIN32_WINNT=0x0501 -DWINVER=0x0501 )
2011-01-20 20:28:21 +00:00
2013-10-14 22:58:11 +00:00
# We need Unicode support
add_definitions ( -DUNICODE -D_UNICODE )
2010-10-16 20:02:12 +00:00
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
$ { C O C O A _ L I B R A R Y }
$ { C A R B O N _ L I B R A R Y }
$ { I O K I T _ L I B R A R Y }
$ { C O R E A U D I O _ L I B R A R Y }
$ { A U D I O U N I T _ L I B R A R Y }
$ { A U D I O T O O L B O X _ L I B R A R Y }
2015-03-16 18:05:13 +00:00
$ { Q U I C K T I M E _ L I B R A R Y } )
2010-10-31 14:54:23 +00:00
# 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 )
2012-01-05 22:45:03 +00:00
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch i386" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch i386" )
2010-10-31 14:54:23 +00:00
endif ( )
# The Mac port simply uses too many deprecated things.
if ( COMPILER_GCC )
set ( WFLAGS "${WFLAGS} -Wno-deprecated-declarations" )
endif ( COMPILER_GCC )
2010-10-16 20:02:12 +00:00
endif ( APPLE )
2010-08-25 19:20:30 +00:00
######################################################################
# Main ASE targets
2010-08-11 00:49:32 +00:00
add_subdirectory ( src )
2010-08-25 19:20:30 +00:00
######################################################################
2010-08-11 00:49:32 +00:00
# Third party libraries
2010-08-25 19:20:30 +00:00
2010-08-11 00:49:32 +00:00
add_subdirectory ( third_party )