2013-12-03 19:31:36 -03:00
|
|
|
# Aseprite
|
2016-02-02 12:21:01 -03:00
|
|
|
# Copyright (C) 2001-2016 David Capello
|
2010-08-10 21:49:32 -03:00
|
|
|
|
2015-03-16 15:05:13 -03:00
|
|
|
######################################################################
|
|
|
|
# Common definitions for all Aseprite libraries/projects
|
|
|
|
|
2012-07-14 16:55:16 -03:00
|
|
|
add_definitions(-DHAVE_CONFIG_H)
|
|
|
|
|
2015-03-16 15:05:13 -03:00
|
|
|
if(ENABLE_MEMLEAK)
|
|
|
|
add_definitions(-DMEMLEAK)
|
|
|
|
endif()
|
|
|
|
|
2014-08-14 00:40:01 -03:00
|
|
|
######################################################################
|
|
|
|
# Compiler-specific flags
|
|
|
|
|
2010-08-25 17:11:28 -03:00
|
|
|
if(MSVC)
|
2015-10-05 21:19:11 -03:00
|
|
|
# As Skia is compiled with /GL flag (whole program optimization),
|
|
|
|
# the linker prefer a /LTCG parameter to improve link times.
|
|
|
|
if(USE_SKIA_BACKEND)
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LTCG")
|
|
|
|
endif()
|
|
|
|
|
2010-08-25 17:11:28 -03:00
|
|
|
# Do not link with libcmt.lib (to avoid duplicated symbols with msvcrtd.lib)
|
|
|
|
if(CMAKE_BUILD_TYPE STREQUAL Debug)
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:LIBCMT")
|
|
|
|
endif()
|
2014-01-05 22:37:53 -03:00
|
|
|
|
2015-03-06 17:01:08 -03:00
|
|
|
if (CMAKE_CL_64)
|
2014-08-14 00:40:01 -03:00
|
|
|
# 64 bits
|
2014-08-12 07:01:21 -03:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MACHINE:X64")
|
|
|
|
else()
|
2014-08-14 00:40:01 -03:00
|
|
|
# Add support for Windows XP with 5.01 subsystem
|
2014-08-12 07:01:21 -03:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MACHINE:X86 /SUBSYSTEM:WINDOWS,5.01")
|
|
|
|
endif()
|
2015-03-05 14:37:16 -03:00
|
|
|
|
|
|
|
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
|
2010-08-25 17:11:28 -03:00
|
|
|
endif(MSVC)
|
|
|
|
|
2015-06-12 18:43:10 -03:00
|
|
|
if(ENABLE_UPDATER)
|
|
|
|
add_definitions(-DENABLE_UPDATER)
|
|
|
|
endif()
|
|
|
|
|
2012-03-15 00:17:49 -03:00
|
|
|
# Directories where .h files can be found
|
|
|
|
include_directories(. .. ../third_party)
|
|
|
|
|
2015-07-13 12:16:55 -03:00
|
|
|
# Use patched version of Allegro 4 (with window resize support).
|
|
|
|
if(USE_ALLEG4_BACKEND AND NOT USE_SHARED_ALLEGRO4)
|
|
|
|
add_subdirectory(allegro)
|
2014-10-25 22:22:58 -03:00
|
|
|
endif()
|
|
|
|
|
2014-08-15 00:26:27 -03:00
|
|
|
######################################################################
|
|
|
|
# Add C++11 support only for our code (avoid Allegro)
|
|
|
|
|
|
|
|
if(UNIX)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-switch -std=gnu++11")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
######################################################################
|
2015-07-13 12:16:55 -03:00
|
|
|
# pthread
|
2014-08-15 00:26:27 -03:00
|
|
|
|
2011-04-28 22:32:37 -03:00
|
|
|
if (CMAKE_USE_PTHREADS_INIT)
|
2015-07-13 12:16:55 -03:00
|
|
|
list(APPEND PLATFORM_LIBS ${CMAKE_THREAD_LIBS_INIT})
|
2011-04-28 22:32:37 -03:00
|
|
|
endif()
|
|
|
|
|
2015-07-13 12:16:55 -03:00
|
|
|
######################################################################
|
|
|
|
# Custom Aseprite website (for testing server-side)
|
|
|
|
|
2014-06-02 21:31:44 -03:00
|
|
|
if(NOT "${CUSTOM_WEBSITE_URL}" STREQUAL "")
|
|
|
|
add_definitions(-DCUSTOM_WEBSITE_URL="${CUSTOM_WEBSITE_URL}")
|
|
|
|
endif()
|
|
|
|
|
2015-07-13 12:16:55 -03:00
|
|
|
######################################################################
|
|
|
|
# Full-version or trial-mode?
|
2013-03-31 00:36:00 -03:00
|
|
|
|
2015-07-13 12:16:55 -03:00
|
|
|
if(NOT USE_SHARED_CURL AND CURL_STATICLIB)
|
|
|
|
add_definitions(-DCURL_STATICLIB)
|
2013-03-31 00:36:00 -03:00
|
|
|
endif()
|
|
|
|
|
2015-07-13 12:16:55 -03:00
|
|
|
######################################################################
|
2014-04-10 00:33:28 -03:00
|
|
|
# Full-version or trial-mode?
|
2015-07-13 12:16:55 -03:00
|
|
|
|
2014-04-10 00:33:28 -03:00
|
|
|
if(NOT ENABLE_TRIAL_MODE)
|
2015-05-09 20:18:10 -03:00
|
|
|
add_definitions(-DENABLE_SAVE -DENABLE_DATA_RECOVERY)
|
2014-04-10 00:33:28 -03:00
|
|
|
else()
|
|
|
|
add_definitions(-DENABLE_TRIAL_MODE)
|
|
|
|
endif()
|
|
|
|
|
2014-08-14 00:40:01 -03:00
|
|
|
######################################################################
|
2013-11-09 19:59:05 -03:00
|
|
|
# Aseprite Libraries (in preferred order to be built)
|
2010-09-23 20:28:16 -03:00
|
|
|
|
|
|
|
add_subdirectory(base)
|
2015-07-13 12:16:55 -03:00
|
|
|
|
|
|
|
# Directory where base/config.h file is located
|
2015-02-12 10:55:58 -03:00
|
|
|
include_directories(${BASE_INCLUDE_DIR})
|
|
|
|
|
2014-10-16 21:27:25 -03:00
|
|
|
add_subdirectory(cfg)
|
2015-09-10 16:10:31 -03:00
|
|
|
add_subdirectory(flic)
|
2014-07-13 13:24:57 -03:00
|
|
|
add_subdirectory(css)
|
2014-03-12 19:25:09 -03:00
|
|
|
add_subdirectory(doc)
|
2014-12-28 11:06:11 -03:00
|
|
|
add_subdirectory(render)
|
2011-06-12 10:50:30 -03:00
|
|
|
add_subdirectory(filters)
|
2014-09-21 11:51:24 -03:00
|
|
|
add_subdirectory(fixmath)
|
2014-07-13 13:24:57 -03:00
|
|
|
add_subdirectory(gen)
|
2010-09-25 16:22:32 -03:00
|
|
|
add_subdirectory(gfx)
|
2012-09-02 17:35:14 -03:00
|
|
|
add_subdirectory(scripting)
|
2012-07-14 16:55:16 -03:00
|
|
|
add_subdirectory(she)
|
2012-06-17 22:49:58 -03:00
|
|
|
add_subdirectory(ui)
|
2015-01-18 22:16:29 -03:00
|
|
|
add_subdirectory(undo)
|
2015-04-23 19:14:13 -03:00
|
|
|
add_subdirectory(net)
|
2010-09-23 20:28:16 -03:00
|
|
|
|
2015-02-12 10:55:58 -03:00
|
|
|
if(ENABLE_UPDATER)
|
|
|
|
add_subdirectory(updater)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(ENABLE_WEBSERVER)
|
|
|
|
add_subdirectory(webserver)
|
|
|
|
endif()
|
|
|
|
|
2013-11-09 19:59:05 -03:00
|
|
|
add_subdirectory(app)
|
|
|
|
|
2010-08-25 17:11:28 -03:00
|
|
|
######################################################################
|
2014-12-02 11:15:06 -03:00
|
|
|
# Copy data/ directory target
|
|
|
|
|
|
|
|
file(GLOB_RECURSE src_data_files
|
|
|
|
RELATIVE ${CMAKE_SOURCE_DIR}/data/ "${CMAKE_SOURCE_DIR}/data/*.*")
|
|
|
|
foreach(fn ${src_data_files})
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${CMAKE_BINARY_DIR}/bin/data/${fn}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/data/${fn} ${CMAKE_BINARY_DIR}/bin/data/${fn}
|
|
|
|
MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/data/${fn})
|
|
|
|
list(APPEND out_data_files ${CMAKE_BINARY_DIR}/bin/data/${fn})
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
add_custom_target(copy_data DEPENDS ${out_data_files})
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# Aseprite application
|
2010-08-25 17:11:28 -03:00
|
|
|
|
2010-10-01 00:23:13 -03:00
|
|
|
if(WIN32)
|
2013-08-05 21:20:19 -03:00
|
|
|
set(win32_resources main/resources_win32.rc)
|
2015-03-16 15:05:13 -03:00
|
|
|
endif()
|
2010-10-01 00:23:13 -03:00
|
|
|
|
2015-03-16 15:05:13 -03:00
|
|
|
if(UNIX AND NOT APPLE AND USE_ALLEG4_BACKEND)
|
2013-08-05 21:20:19 -03:00
|
|
|
set(x11_resources main/xpm_icon.c)
|
2015-03-16 15:05:13 -03:00
|
|
|
endif()
|
2011-09-06 19:37:35 -03:00
|
|
|
|
2014-12-02 11:15:06 -03:00
|
|
|
add_executable(aseprite WIN32
|
|
|
|
main/main.cpp
|
|
|
|
${win32_resources}
|
|
|
|
${x11_resources})
|
2015-07-13 12:16:55 -03:00
|
|
|
target_link_libraries(aseprite app-lib ${PLATFORM_LIBS})
|
2014-12-02 11:15:06 -03:00
|
|
|
add_dependencies(aseprite copy_data)
|
2010-08-10 21:49:32 -03:00
|
|
|
|
2011-06-12 10:50:30 -03:00
|
|
|
install(TARGETS aseprite
|
2010-10-12 17:19:19 -07:00
|
|
|
RUNTIME DESTINATION bin)
|
|
|
|
|
2011-06-12 10:50:30 -03:00
|
|
|
install(DIRECTORY ../data
|
2010-10-12 17:19:19 -07:00
|
|
|
DESTINATION share/aseprite)
|
|
|
|
|
2010-08-25 17:11:52 -03:00
|
|
|
######################################################################
|
2014-06-28 10:49:38 -03:00
|
|
|
# Tests
|
2010-08-25 17:11:52 -03:00
|
|
|
|
2014-06-28 10:49:38 -03:00
|
|
|
function(find_tests dir dependencies)
|
|
|
|
file(GLOB tests ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/*_tests.cpp)
|
2011-03-18 00:26:08 -03:00
|
|
|
list(REMOVE_AT ARGV 0)
|
2010-09-14 19:52:02 -03:00
|
|
|
|
2015-06-09 10:54:04 -03:00
|
|
|
# Add gtest include directory so we can #include <gtest/gtest.h> in tests source code
|
|
|
|
include_directories(${CMAKE_SOURCE_DIR}/third_party/gtest/include)
|
2010-12-12 09:53:39 -03:00
|
|
|
|
2012-08-24 00:49:38 -03:00
|
|
|
# See if the test is linked with "she" library.
|
2014-04-12 12:29:55 -03:00
|
|
|
list(FIND dependencies she link_with_she)
|
|
|
|
if(link_with_she)
|
2012-08-24 00:49:38 -03:00
|
|
|
set(extra_definitions -DLINKED_WITH_SHE)
|
|
|
|
endif()
|
|
|
|
|
2011-03-18 00:26:08 -03:00
|
|
|
foreach(testsourcefile ${tests})
|
|
|
|
get_filename_component(testname ${testsourcefile} NAME_WE)
|
2010-08-25 17:11:52 -03:00
|
|
|
|
2011-03-18 00:26:08 -03:00
|
|
|
add_executable(${testname} ${testsourcefile})
|
2015-09-21 16:45:25 -03:00
|
|
|
add_test(NAME ${testname} COMMAND ${testname})
|
2014-12-02 01:38:25 -03:00
|
|
|
|
|
|
|
if(MSVC)
|
|
|
|
# Fix problem compiling gen from a Visual Studio solution
|
|
|
|
set_target_properties(${testname}
|
|
|
|
PROPERTIES LINK_FLAGS -ENTRY:"mainCRTStartup")
|
|
|
|
endif()
|
|
|
|
|
2015-07-13 13:01:48 -03:00
|
|
|
target_link_libraries(${testname} gtest ${ARGV} ${PLATFORM_LIBS})
|
2010-08-10 21:49:32 -03:00
|
|
|
|
2012-08-24 00:49:38 -03:00
|
|
|
if(extra_definitions)
|
|
|
|
set_target_properties(${testname}
|
|
|
|
PROPERTIES COMPILE_FLAGS ${extra_definitions})
|
|
|
|
endif()
|
2011-03-18 00:26:08 -03:00
|
|
|
endforeach()
|
|
|
|
endfunction()
|
|
|
|
|
2015-07-13 12:16:55 -03:00
|
|
|
find_tests(base base-lib)
|
|
|
|
find_tests(undo undo-lib)
|
|
|
|
find_tests(gfx gfx-lib)
|
|
|
|
find_tests(doc doc-lib)
|
|
|
|
find_tests(render render-lib)
|
|
|
|
find_tests(css css-lib)
|
|
|
|
find_tests(ui ui-lib)
|
|
|
|
find_tests(app/file app-lib)
|
|
|
|
find_tests(app app-lib)
|
|
|
|
find_tests(. app-lib)
|