2013-12-03 22:31:36 +00:00
|
|
|
# Aseprite
|
2015-01-19 01:05:33 +00:00
|
|
|
# Copyright (C) 2001-2015 David Capello
|
2010-08-11 00:49:32 +00:00
|
|
|
|
2015-03-16 18:05:13 +00:00
|
|
|
######################################################################
|
|
|
|
# Common definitions for all Aseprite libraries/projects
|
|
|
|
|
2012-07-14 19:55:16 +00:00
|
|
|
add_definitions(-DHAVE_CONFIG_H)
|
|
|
|
|
2015-03-16 18:05:13 +00:00
|
|
|
if(ENABLE_MEMLEAK)
|
|
|
|
add_definitions(-DMEMLEAK)
|
|
|
|
endif()
|
|
|
|
|
2014-08-14 03:40:01 +00:00
|
|
|
######################################################################
|
|
|
|
# Compiler-specific flags
|
|
|
|
|
2010-08-25 20:11:28 +00:00
|
|
|
if(MSVC)
|
|
|
|
# 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-06 01:37:53 +00:00
|
|
|
|
2015-03-06 20:01:08 +00:00
|
|
|
if (CMAKE_CL_64)
|
2014-08-14 03:40:01 +00:00
|
|
|
# 64 bits
|
2014-08-12 10:01:21 +00:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MACHINE:X64")
|
|
|
|
else()
|
2014-08-14 03:40:01 +00:00
|
|
|
# Add support for Windows XP with 5.01 subsystem
|
2014-08-12 10:01:21 +00:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MACHINE:X86 /SUBSYSTEM:WINDOWS,5.01")
|
|
|
|
endif()
|
2015-03-05 17:37:16 +00:00
|
|
|
|
|
|
|
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
|
2010-08-25 20:11:28 +00:00
|
|
|
endif(MSVC)
|
|
|
|
|
2015-06-12 21:43:10 +00:00
|
|
|
if(ENABLE_UPDATER)
|
|
|
|
set(updater_lib updater-lib)
|
|
|
|
add_definitions(-DENABLE_UPDATER)
|
|
|
|
else()
|
|
|
|
set(updater_lib)
|
|
|
|
endif()
|
|
|
|
|
2012-03-15 03:17:49 +00:00
|
|
|
# Directories where .h files can be found
|
|
|
|
include_directories(. .. ../third_party)
|
|
|
|
|
2015-07-13 15:16:55 +00: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-26 01:22:58 +00:00
|
|
|
endif()
|
|
|
|
|
2014-08-15 03:26:27 +00: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 15:16:55 +00:00
|
|
|
# pthread
|
2014-08-15 03:26:27 +00:00
|
|
|
|
2011-04-29 01:32:37 +00:00
|
|
|
if (CMAKE_USE_PTHREADS_INIT)
|
2015-07-13 15:16:55 +00:00
|
|
|
list(APPEND PLATFORM_LIBS ${CMAKE_THREAD_LIBS_INIT})
|
2011-04-29 01:32:37 +00:00
|
|
|
endif()
|
|
|
|
|
2015-07-13 15:16:55 +00:00
|
|
|
######################################################################
|
|
|
|
# Custom Aseprite website (for testing server-side)
|
|
|
|
|
2014-06-03 00:31:44 +00:00
|
|
|
if(NOT "${CUSTOM_WEBSITE_URL}" STREQUAL "")
|
|
|
|
add_definitions(-DCUSTOM_WEBSITE_URL="${CUSTOM_WEBSITE_URL}")
|
|
|
|
endif()
|
|
|
|
|
2015-07-13 15:16:55 +00:00
|
|
|
######################################################################
|
|
|
|
# Full-version or trial-mode?
|
2013-03-31 03:36:00 +00:00
|
|
|
|
2015-07-13 15:16:55 +00:00
|
|
|
if(NOT USE_SHARED_CURL AND CURL_STATICLIB)
|
|
|
|
add_definitions(-DCURL_STATICLIB)
|
2013-03-31 03:36:00 +00:00
|
|
|
endif()
|
|
|
|
|
2015-07-13 15:16:55 +00:00
|
|
|
######################################################################
|
2014-04-10 03:33:28 +00:00
|
|
|
# Full-version or trial-mode?
|
2015-07-13 15:16:55 +00:00
|
|
|
|
2014-04-10 03:33:28 +00:00
|
|
|
if(NOT ENABLE_TRIAL_MODE)
|
2015-05-09 23:18:10 +00:00
|
|
|
add_definitions(-DENABLE_SAVE -DENABLE_DATA_RECOVERY)
|
2014-04-10 03:33:28 +00:00
|
|
|
else()
|
|
|
|
add_definitions(-DENABLE_TRIAL_MODE)
|
|
|
|
endif()
|
|
|
|
|
2014-08-14 03:40:01 +00:00
|
|
|
######################################################################
|
2013-11-09 22:59:05 +00:00
|
|
|
# Aseprite Libraries (in preferred order to be built)
|
2010-09-23 23:28:16 +00:00
|
|
|
|
|
|
|
add_subdirectory(base)
|
2015-07-13 15:16:55 +00:00
|
|
|
|
|
|
|
# Directory where base/config.h file is located
|
2015-02-12 13:55:58 +00:00
|
|
|
include_directories(${BASE_INCLUDE_DIR})
|
|
|
|
|
2014-10-17 00:27:25 +00:00
|
|
|
add_subdirectory(cfg)
|
2014-07-13 16:24:57 +00:00
|
|
|
add_subdirectory(css)
|
2014-03-12 22:25:09 +00:00
|
|
|
add_subdirectory(doc)
|
2014-12-28 14:06:11 +00:00
|
|
|
add_subdirectory(render)
|
2011-06-12 13:50:30 +00:00
|
|
|
add_subdirectory(filters)
|
2014-09-21 14:51:24 +00:00
|
|
|
add_subdirectory(fixmath)
|
2014-07-13 16:24:57 +00:00
|
|
|
add_subdirectory(gen)
|
2010-09-25 19:22:32 +00:00
|
|
|
add_subdirectory(gfx)
|
2012-09-02 20:35:14 +00:00
|
|
|
add_subdirectory(scripting)
|
2012-07-14 19:55:16 +00:00
|
|
|
add_subdirectory(she)
|
2012-06-18 01:49:58 +00:00
|
|
|
add_subdirectory(ui)
|
2015-01-19 01:16:29 +00:00
|
|
|
add_subdirectory(undo)
|
2015-04-23 22:14:13 +00:00
|
|
|
add_subdirectory(net)
|
2010-09-23 23:28:16 +00:00
|
|
|
|
2015-02-12 13:55:58 +00:00
|
|
|
if(ENABLE_UPDATER)
|
|
|
|
add_subdirectory(updater)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(ENABLE_WEBSERVER)
|
|
|
|
add_subdirectory(webserver)
|
|
|
|
endif()
|
|
|
|
|
2013-11-09 22:59:05 +00:00
|
|
|
add_subdirectory(app)
|
|
|
|
|
2015-03-16 18:05:13 +00:00
|
|
|
if(USE_SKIA_BACKEND)
|
2015-07-13 15:16:55 +00:00
|
|
|
list(APPEND PLATFORM_LIBS ${SKIA_LIBRARIES})
|
2013-01-02 00:01:29 +00:00
|
|
|
endif()
|
|
|
|
|
2010-08-25 20:11:28 +00:00
|
|
|
######################################################################
|
2014-12-02 14:15:06 +00: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 20:11:28 +00:00
|
|
|
|
2010-10-01 03:23:13 +00:00
|
|
|
if(WIN32)
|
2013-08-06 00:20:19 +00:00
|
|
|
set(win32_resources main/resources_win32.rc)
|
2015-03-16 18:05:13 +00:00
|
|
|
endif()
|
2010-10-01 03:23:13 +00:00
|
|
|
|
2015-03-16 18:05:13 +00:00
|
|
|
if(UNIX AND NOT APPLE AND USE_ALLEG4_BACKEND)
|
2013-08-06 00:20:19 +00:00
|
|
|
set(x11_resources main/xpm_icon.c)
|
2015-03-16 18:05:13 +00:00
|
|
|
endif()
|
2011-09-06 22:37:35 +00:00
|
|
|
|
2014-12-02 14:15:06 +00:00
|
|
|
add_executable(aseprite WIN32
|
|
|
|
main/main.cpp
|
|
|
|
${win32_resources}
|
|
|
|
${x11_resources})
|
2015-07-13 15:16:55 +00:00
|
|
|
target_link_libraries(aseprite app-lib ${PLATFORM_LIBS})
|
2014-12-02 14:15:06 +00:00
|
|
|
add_dependencies(aseprite copy_data)
|
2010-08-11 00:49:32 +00:00
|
|
|
|
2011-06-12 13:50:30 +00:00
|
|
|
install(TARGETS aseprite
|
2010-10-13 00:19:19 +00:00
|
|
|
RUNTIME DESTINATION bin)
|
|
|
|
|
2011-06-12 13:50:30 +00:00
|
|
|
install(DIRECTORY ../data
|
2010-10-13 00:19:19 +00:00
|
|
|
DESTINATION share/aseprite)
|
|
|
|
|
2010-08-25 20:11:52 +00:00
|
|
|
######################################################################
|
2014-06-28 13:49:38 +00:00
|
|
|
# Tests
|
2010-08-25 20:11:52 +00:00
|
|
|
|
2014-06-28 13:49:38 +00:00
|
|
|
function(find_tests dir dependencies)
|
|
|
|
file(GLOB tests ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/*_tests.cpp)
|
2011-03-18 03:26:08 +00:00
|
|
|
list(REMOVE_AT ARGV 0)
|
2010-09-14 22:52:02 +00:00
|
|
|
|
2015-06-09 13:54:04 +00: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 12:53:39 +00:00
|
|
|
|
2012-08-24 03:49:38 +00:00
|
|
|
# See if the test is linked with "she" library.
|
2014-04-12 15:29:55 +00:00
|
|
|
list(FIND dependencies she link_with_she)
|
|
|
|
if(link_with_she)
|
2012-08-24 03:49:38 +00:00
|
|
|
set(extra_definitions -DLINKED_WITH_SHE)
|
|
|
|
endif()
|
|
|
|
|
2011-03-18 03:26:08 +00:00
|
|
|
foreach(testsourcefile ${tests})
|
|
|
|
get_filename_component(testname ${testsourcefile} NAME_WE)
|
2010-08-25 20:11:52 +00:00
|
|
|
|
2011-03-18 03:26:08 +00:00
|
|
|
add_executable(${testname} ${testsourcefile})
|
2014-12-02 04:38:25 +00: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 16:01:48 +00:00
|
|
|
target_link_libraries(${testname} gtest ${ARGV} ${PLATFORM_LIBS})
|
2010-08-11 00:49:32 +00:00
|
|
|
|
2012-08-24 03:49:38 +00:00
|
|
|
if(extra_definitions)
|
|
|
|
set_target_properties(${testname}
|
|
|
|
PROPERTIES COMPILE_FLAGS ${extra_definitions})
|
|
|
|
endif()
|
|
|
|
|
2011-03-18 03:26:08 +00:00
|
|
|
add_custom_target(run_${testname}
|
|
|
|
COMMAND ${testname}
|
|
|
|
DEPENDS ${testname})
|
2010-08-25 23:13:51 +00:00
|
|
|
|
2011-03-18 03:26:08 +00:00
|
|
|
set(local_runs ${local_runs} run_${testname})
|
2012-03-22 17:55:28 +00:00
|
|
|
|
2014-06-28 13:49:38 +00:00
|
|
|
string(REGEX MATCH "_ui_tests" test_requires_ui ${testname})
|
|
|
|
if (NOT test_requires_ui STREQUAL "_ui_tests")
|
2012-03-22 17:55:28 +00:00
|
|
|
set(local_non_ui_runs ${local_non_ui_runs} run_${testname})
|
|
|
|
endif()
|
2011-03-18 03:26:08 +00:00
|
|
|
endforeach()
|
|
|
|
set(all_runs ${all_runs} ${local_runs} PARENT_SCOPE)
|
2012-03-22 17:55:28 +00:00
|
|
|
set(non_ui_runs ${non_ui_runs} ${local_non_ui_runs} PARENT_SCOPE)
|
2011-03-18 03:26:08 +00:00
|
|
|
endfunction()
|
|
|
|
|
2015-07-13 15:16:55 +00: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)
|
2010-08-25 23:13:51 +00:00
|
|
|
|
|
|
|
# To run tests
|
2014-06-28 13:49:38 +00:00
|
|
|
add_custom_target(run_all_tests DEPENDS ${all_runs})
|
|
|
|
add_custom_target(run_non_ui_tests DEPENDS ${non_ui_runs})
|