2013-12-03 22:31:36 +00:00
|
|
|
# Aseprite
|
2014-07-13 16:24:57 +00:00
|
|
|
# Copyright (C) 2001-2014 David Capello
|
2010-08-11 00:49:32 +00:00
|
|
|
|
2012-07-14 19:55:16 +00:00
|
|
|
add_definitions(-DHAVE_CONFIG_H)
|
|
|
|
|
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
|
|
|
|
2014-08-12 10:01:21 +00:00
|
|
|
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
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()
|
2010-08-25 20:11:28 +00:00
|
|
|
endif(MSVC)
|
|
|
|
|
2012-03-15 03:17:49 +00:00
|
|
|
# Libraries in this directory
|
2014-09-21 15:13:13 +00:00
|
|
|
set(aseprite_libraries
|
|
|
|
app-lib
|
|
|
|
fixmath-lib
|
|
|
|
css-lib
|
|
|
|
doc-lib
|
|
|
|
raster-lib
|
|
|
|
scripting-lib
|
|
|
|
undo-lib
|
|
|
|
filters-lib
|
|
|
|
ui-lib
|
|
|
|
she
|
|
|
|
gfx-lib
|
|
|
|
base-lib)
|
2012-03-15 03:17:49 +00:00
|
|
|
|
|
|
|
# Directories where .h files can be found
|
|
|
|
include_directories(. .. ../third_party)
|
|
|
|
|
2014-07-13 16:24:57 +00:00
|
|
|
# Directory where generated files by "gen" utility will stay.
|
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
|
2010-08-11 00:49:32 +00:00
|
|
|
# Third-party libraries
|
2010-09-30 20:04:32 +00:00
|
|
|
|
2014-08-15 03:26:27 +00:00
|
|
|
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)
|
|
|
|
|
|
|
|
include_directories(${LIBALLEGRO4_INCLUDE_DIR})
|
|
|
|
else()
|
|
|
|
add_definitions(-DALLEGRO4_WITH_RESIZE_PATCH)
|
|
|
|
add_definitions(-DALLEGRO4_WITH_EXTRA_CURSORS)
|
|
|
|
|
|
|
|
# Use patched version of Allegro 4 (with window resize support).
|
|
|
|
add_subdirectory(allegro)
|
|
|
|
set(libs3rdparty ${libs3rdparty} allegro)
|
|
|
|
endif()
|
|
|
|
|
2010-09-30 20:04:32 +00:00
|
|
|
if(USE_SHARED_JPEGLIB)
|
|
|
|
find_package(JPEG)
|
|
|
|
if(JPEG_FOUND)
|
|
|
|
set(libs3rdparty ${libs3rdparty} ${JPEG_LIBRARIES})
|
|
|
|
include_directories(${JPEG_INCLUDE_DIR})
|
|
|
|
endif(JPEG_FOUND)
|
|
|
|
else()
|
|
|
|
set(libs3rdparty ${libs3rdparty} jpeg)
|
2012-03-15 03:17:49 +00:00
|
|
|
include_directories(${LIBJPEG_DIR})
|
2010-09-30 20:04:32 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(USE_SHARED_ZLIB)
|
|
|
|
find_package(ZLIB)
|
|
|
|
if(ZLIB_FOUND)
|
|
|
|
set(libs3rdparty ${libs3rdparty} ${ZLIB_LIBRARIES})
|
|
|
|
include_directories(${ZLIB_INCLUDE_DIR})
|
|
|
|
endif(ZLIB_FOUND)
|
|
|
|
else()
|
|
|
|
set(libs3rdparty ${libs3rdparty} zlib)
|
2012-03-15 03:17:49 +00:00
|
|
|
include_directories(${ZLIB_DIR})
|
2010-09-30 20:04:32 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(USE_SHARED_LIBPNG)
|
|
|
|
find_package(PNG)
|
|
|
|
if(PNG_FOUND)
|
|
|
|
set(libs3rdparty ${libs3rdparty} ${PNG_LIBRARIES})
|
|
|
|
add_definitions(${PNG_DEFINITIONS})
|
|
|
|
include_directories(${PNG_INCLUDE_DIR})
|
|
|
|
endif(PNG_FOUND)
|
|
|
|
else()
|
|
|
|
set(libs3rdparty ${libs3rdparty} libpng)
|
|
|
|
endif()
|
2010-08-25 20:11:28 +00:00
|
|
|
|
2012-03-15 03:17:49 +00:00
|
|
|
if(USE_SHARED_GIFLIB)
|
2012-03-19 17:29:29 +00:00
|
|
|
find_package(GIF REQUIRED)
|
|
|
|
if(GIF_FOUND)
|
|
|
|
set(libs3rdparty ${libs3rdparty} ${GIF_LIBRARIES})
|
|
|
|
include_directories(${GIF_INCLUDE_DIR})
|
|
|
|
endif(GIF_FOUND)
|
2012-03-15 03:17:49 +00:00
|
|
|
else()
|
|
|
|
set(libs3rdparty ${libs3rdparty} giflib)
|
|
|
|
include_directories(${GIFLIB_DIR}/lib)
|
2011-06-12 13:50:30 +00:00
|
|
|
endif()
|
|
|
|
|
2012-03-19 17:04:24 +00:00
|
|
|
if(USE_SHARED_TINYXML)
|
|
|
|
find_library(LIBTINYXML_LIBRARY NAMES tinyxml)
|
|
|
|
find_path(LIBTINYXML_INCLUDE_DIR NAMES tinyxml.h)
|
|
|
|
|
|
|
|
set(libs3rdparty ${libs3rdparty} ${LIBTINYXML_LIBRARY})
|
|
|
|
include_directories(${LIBTINYXML_INCLUDE_DIR})
|
|
|
|
else()
|
|
|
|
set(libs3rdparty ${libs3rdparty} tinyxml)
|
|
|
|
include_directories(${TINYXML_DIR})
|
|
|
|
endif()
|
|
|
|
|
2012-07-09 00:21:01 +00:00
|
|
|
if(USE_SHARED_LIBLOADPNG)
|
|
|
|
find_library(LIBLOADPNG_LIBRARY NAMES loadpng)
|
|
|
|
find_path(LIBLOADPNG_INCLUDE_DIR NAMES loadpng.h)
|
|
|
|
|
|
|
|
set(libs3rdparty ${libs3rdparty} ${LIBLOADPNG_LIBRARY})
|
|
|
|
include_directories(${LIBLOADPNG_INCLUDE_DIR})
|
|
|
|
else()
|
2012-08-12 17:49:24 +00:00
|
|
|
set(libs3rdparty loadpng ${libs3rdparty})
|
2012-07-09 00:21:01 +00:00
|
|
|
include_directories(${LOADPNG_DIR})
|
|
|
|
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()
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# Updater
|
|
|
|
|
2011-04-29 01:32:37 +00:00
|
|
|
if (CMAKE_USE_PTHREADS_INIT)
|
|
|
|
set(sys_libs ${sys_libs} ${CMAKE_THREAD_LIBS_INIT})
|
|
|
|
endif()
|
|
|
|
|
2014-06-03 00:31:44 +00:00
|
|
|
if(NOT "${CUSTOM_WEBSITE_URL}" STREQUAL "")
|
|
|
|
add_definitions(-DCUSTOM_WEBSITE_URL="${CUSTOM_WEBSITE_URL}")
|
|
|
|
endif()
|
|
|
|
|
2011-07-28 00:26:22 +00:00
|
|
|
if(ENABLE_UPDATER)
|
2012-03-15 03:17:49 +00:00
|
|
|
if(USE_SHARED_CURL)
|
2012-03-19 17:29:54 +00:00
|
|
|
find_library(LIBCURL_LIBRARY NAMES curl)
|
|
|
|
find_path(LIBCURL_INCLUDE_DIR NAMES curl/curl.h)
|
2012-03-15 03:17:49 +00:00
|
|
|
|
|
|
|
set(libs3rdparty ${libs3rdparty} ${LIBCURL_LIBRARY})
|
|
|
|
include_directories(${LIBCURL_INCLUDE_DIR})
|
|
|
|
else()
|
|
|
|
set(libs3rdparty ${libs3rdparty} libcurl)
|
|
|
|
include_directories(${CURL_DIR}/include)
|
|
|
|
if(CURL_STATICLIB)
|
|
|
|
add_definitions(-DCURL_STATICLIB)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2011-07-28 02:08:54 +00:00
|
|
|
set(aseprite_libraries ${aseprite_libraries} updater-lib net-lib)
|
2011-07-28 00:26:22 +00:00
|
|
|
add_definitions(-DENABLE_UPDATER)
|
2012-03-19 17:28:06 +00:00
|
|
|
|
|
|
|
add_subdirectory(net)
|
2012-03-19 16:24:34 +00:00
|
|
|
add_subdirectory(updater)
|
2011-07-28 00:26:22 +00:00
|
|
|
endif()
|
|
|
|
|
2013-03-31 03:36:00 +00:00
|
|
|
if(ENABLE_WEBSERVER)
|
|
|
|
set(libs3rdparty ${libs3rdparty} mongoose)
|
|
|
|
include_directories(${MONGOOSE_DIR})
|
|
|
|
|
|
|
|
set(aseprite_libraries ${aseprite_libraries} webserver-lib)
|
|
|
|
add_definitions(-DENABLE_WEBSERVER)
|
|
|
|
|
|
|
|
add_subdirectory(webserver)
|
|
|
|
endif()
|
|
|
|
|
2014-04-10 03:33:28 +00:00
|
|
|
# Full-version or trial-mode?
|
|
|
|
if(NOT ENABLE_TRIAL_MODE)
|
|
|
|
add_definitions(-DENABLE_SAVE)
|
|
|
|
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)
|
2014-07-13 16:24:57 +00:00
|
|
|
add_subdirectory(css)
|
2014-03-12 22:25:09 +00:00
|
|
|
add_subdirectory(doc)
|
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)
|
2013-08-06 00:20:19 +00:00
|
|
|
add_subdirectory(raster)
|
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)
|
2011-03-26 20:40:55 +00:00
|
|
|
add_subdirectory(undo)
|
2010-09-23 23:28:16 +00:00
|
|
|
|
2013-11-09 22:59:05 +00:00
|
|
|
add_subdirectory(app)
|
|
|
|
|
2012-09-02 20:35:14 +00:00
|
|
|
if(V8_FOUND)
|
|
|
|
list(APPEND libs3rdparty ${V8_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# All libraries for .exe files
|
|
|
|
set(all_libs ${aseprite_libraries} ${libs3rdparty} ${sys_libs})
|
|
|
|
|
2013-01-02 00:01:29 +00:00
|
|
|
if(LIBALLEGRO4_LINK_FLAGS)
|
|
|
|
set(all_libs ${all_libs} ${LIBALLEGRO4_LINK_FLAGS})
|
|
|
|
endif()
|
|
|
|
|
2010-08-25 20:11:28 +00:00
|
|
|
######################################################################
|
2012-03-19 16:24:15 +00:00
|
|
|
# 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)
|
2010-10-01 03:23:13 +00:00
|
|
|
endif(WIN32)
|
|
|
|
|
2011-09-06 22:37:35 +00:00
|
|
|
if(UNIX)
|
2013-08-06 00:20:19 +00:00
|
|
|
set(x11_resources main/xpm_icon.c)
|
2011-09-06 22:37:35 +00:00
|
|
|
endif(UNIX)
|
|
|
|
|
2013-08-06 00:20:19 +00:00
|
|
|
add_executable(aseprite WIN32 main/main.cpp ${win32_resources} ${x11_resources})
|
2010-10-12 13:21:52 +00:00
|
|
|
target_link_libraries(aseprite ${all_libs})
|
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)
|
|
|
|
|
|
|
|
if(EXISTS ../docs/quickref.pdf)
|
2011-06-12 13:50:30 +00:00
|
|
|
install(FILES ../docs/quickref.pdf
|
2010-10-13 00:19:19 +00:00
|
|
|
DESTINATION share/aseprite/docs/quickref.pdf)
|
|
|
|
endif()
|
|
|
|
|
2014-07-13 16:24:57 +00:00
|
|
|
######################################################################
|
|
|
|
# Generate source files from widget XML files
|
|
|
|
|
|
|
|
file(GLOB widget_files ${CMAKE_SOURCE_DIR}/data/widgets/*.xml)
|
|
|
|
foreach(widget_file ${widget_files})
|
|
|
|
get_filename_component(widget_name ${widget_file} NAME_WE)
|
|
|
|
set(target_name generated_${widget_name})
|
|
|
|
set(output_fn ${CMAKE_CURRENT_BINARY_DIR}/generated_${widget_name}.h)
|
|
|
|
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${output_fn}
|
|
|
|
COMMAND gen/gen --input ${widget_file} --widgetid ${widget_name} > ${output_fn}
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
MAIN_DEPENDENCY ${widget_file}
|
|
|
|
DEPENDS gen)
|
|
|
|
|
|
|
|
add_custom_target(${target_name} DEPENDS ${output_fn})
|
|
|
|
|
|
|
|
set_source_files_properties(${target_name} PROPERTIES GENERATED TRUE)
|
|
|
|
|
|
|
|
add_dependencies(app-lib ${target_name})
|
|
|
|
endforeach()
|
|
|
|
|
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
|
|
|
|
2012-03-19 17:33:49 +00:00
|
|
|
if(NOT USE_SHARED_GTEST)
|
|
|
|
# Add gtest include directory so we can #include <gtest/gtest.h> in tests source code
|
|
|
|
include_directories(${CMAKE_SOURCE_DIR}/third_party/gtest/include)
|
|
|
|
endif()
|
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})
|
|
|
|
target_link_libraries(${testname} gtest ${ARGV})
|
2012-03-19 16:24:15 +00:00
|
|
|
if(LIBALLEGRO4_LINK_FLAGS)
|
2013-01-02 00:01:29 +00:00
|
|
|
target_link_libraries(${testname} ${LIBALLEGRO4_LINK_FLAGS})
|
2012-03-19 16:24:15 +00:00
|
|
|
endif()
|
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()
|
|
|
|
|
2014-06-28 13:49:38 +00:00
|
|
|
find_tests(base base-lib ${sys_libs})
|
|
|
|
find_tests(gfx gfx-lib base-lib ${sys_libs})
|
|
|
|
find_tests(raster raster-lib gfx-lib base-lib ${libs3rdparty} ${sys_libs})
|
2014-07-29 03:53:24 +00:00
|
|
|
find_tests(doc doc-lib raster-lib gfx-lib base-lib ${libs3rdparty} ${sys_libs})
|
2014-06-28 13:49:38 +00:00
|
|
|
find_tests(css css-lib gfx-lib base-lib ${libs3rdparty} ${sys_libs})
|
|
|
|
find_tests(ui ui-lib she gfx-lib base-lib ${libs3rdparty} ${sys_libs})
|
2014-07-07 01:10:48 +00:00
|
|
|
find_tests(app/file ${all_libs})
|
2014-06-28 13:49:38 +00:00
|
|
|
find_tests(app ${all_libs})
|
|
|
|
find_tests(. ${all_libs})
|
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})
|