-
Notifications
You must be signed in to change notification settings - Fork 10
/
CMakeLists.txt
147 lines (130 loc) · 4.53 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
cmake_minimum_required(VERSION 3.12)
project(spright)
set(CMAKE_CONFIGURATION_TYPES "Debug" "Release")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type" FORCE)
endif()
find_package(Git)
if(NOT VERSION AND GIT_FOUND)
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
configure_file("src/version.h.in" "${CMAKE_SOURCE_DIR}/src/_version.h")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
set(SOURCES
src/common.cpp
src/Rect.cpp
src/settings.cpp
src/image.cpp
src/input.cpp
src/InputParser.cpp
src/Definition.cpp
src/trimming.cpp
src/packing.cpp
src/pack_binpack.cpp
src/pack_compact.cpp
src/pack_single.cpp
src/pack_origin.cpp
src/pack_keep.cpp
src/pack_lines.cpp
src/output_texture.cpp
src/output_description.cpp
src/globbing.cpp
src/debug.cpp
src/main.cpp
libs/rect_pack/rect_pack.cpp
)
if(NOT MSVC)
set_source_files_properties(${SOURCES}
PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wsign-conversion -Wconversion -Wno-missing-field-initializers")
endif()
file(GLOB CHIPMUNK_SOURCES libs/chipmunk/src/*.c)
list(FILTER CHIPMUNK_SOURCES EXCLUDE REGEX ".*(Spring|Joint|Motor).c$")
add_compile_definitions(CP_SPACE_DISABLE_DEBUG_API)
set(SOURCES ${SOURCES}
libs/rect_pack/stb_rect_pack.cpp
libs/rect_pack/MaxRectsBinPack.cpp
libs/stb/stb_impl.cpp
libs/miniz/miniz.c
libs/gifenc/gifenc.c
libs/cpp-base64/base64.cpp
${CHIPMUNK_SOURCES}
)
set(INCLUDES ${INCLUDES}
libs
libs/chipmunk/include
)
file(GLOB_RECURSE HEADERS include src/**.h libs/*.hpp libs/**.h )
if(UNIX AND NOT APPLE)
link_libraries(stdc++fs pthread)
elseif(WIN32)
add_compile_definitions(UNICODE _WIN32_WINNT=0x0501)
set(SOURCES ${SOURCES}
libs/utf8_console/utf8_console.cpp
)
if(MSVC)
add_compile_options(/GR- /GL /Os /MP /W3 /wd4100)
add_link_options($<$<CONFIG:RELEASE>:/LTCG>)
add_compile_options($<$<CONFIG:RELEASE>:/MT>)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNINGS)
endif()
endif()
include_directories(.)
include_directories(SYSTEM ${INCLUDES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCES} ${HEADERS})
add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS})
option(ENABLE_TEST "Enable tests")
if(ENABLE_TEST)
set(TEST_SOURCES ${SOURCES}
test/catch.cpp
test/test-main.cpp
test/test-common.cpp
test/test-scope.cpp
test/test-autocompletion.cpp
test/test-packing.cpp
test/test-performance.cpp
test/test-globbing.cpp
test/test-templates.cpp
test/test-pivot.cpp
)
list(REMOVE_ITEM TEST_SOURCES src/main.cpp)
set(CMAKE_CXX_STANDARD 20)
add_executable(spright-tests ${TEST_SOURCES})
add_compile_definitions(EMBED_TEST_FILES)
endif()
# install
option(PORTABLE "Install files for a portable package")
if(NOT PORTABLE AND NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
# normal installation
install(TARGETS ${PROJECT_NAME} DESTINATION "bin" COMPONENT Application)
install(DIRECTORY templates DESTINATION "share/spright" COMPONENT Application)
else()
# portable package (.ZIP)
set(DOC_FILES LICENSE README.md CHANGELOG.md THIRD-PARTY.md)
install(TARGETS ${PROJECT_NAME} DESTINATION . COMPONENT Application)
install(FILES ${DOC_FILES} DESTINATION . COMPONENT Application)
install(DIRECTORY templates DESTINATION . COMPONENT Application)
endif()
# package
set(CPACK_PACKAGE_NAME "Spright")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "An advanced sprite sheet packer and sprite annotator")
set(CPACK_PACKAGE_VENDOR "Albert Kalchmair")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "spright")
set(CPACK_PACKAGE_EXECUTABLES "spright;spright")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/houmain/spright")
set(CPACK_PACKAGE_CONTACT ${CPACK_PACKAGE_HOMEPAGE_URL})
set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
set(CPACK_STRIP_FILES TRUE)
set(CPACK_DEBIAN_PACKAGE_SECTION utils)
set(CPACK_RPM_PACKAGE_LICENSE "GPLv3")
if(VERSION MATCHES "^[0-9]+\.[0-9]+\.[0-9]+")
string(REGEX MATCHALL "[0-9]+" VERSION_LIST "${VERSION}")
list(GET VERSION_LIST 0 CPACK_PACKAGE_VERSION_MAJOR)
list(GET VERSION_LIST 1 CPACK_PACKAGE_VERSION_MINOR)
list(GET VERSION_LIST 2 CPACK_PACKAGE_VERSION_PATCH)
endif()
include(CPack)