-
-
Notifications
You must be signed in to change notification settings - Fork 129
/
CMakeLists.txt
116 lines (97 loc) · 3 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
cmake_minimum_required(VERSION 3.15)
set(LUNASVG_VERSION_MAJOR 3)
set(LUNASVG_VERSION_MINOR 1)
set(LUNASVG_VERSION_MICRO 0)
project(lunasvg LANGUAGES CXX VERSION ${LUNASVG_VERSION_MAJOR}.${LUNASVG_VERSION_MINOR}.${LUNASVG_VERSION_MICRO})
include(FetchContent)
FetchContent_Declare(plutovg
GIT_REPOSITORY https://github.com/sammycage/plutovg.git
GIT_TAG main
GIT_SHALLOW ON
FIND_PACKAGE_ARGS 0.0.4
)
FetchContent_MakeAvailable(plutovg)
set(lunasvg_sources
source/lunasvg.cpp
source/graphics.cpp
source/svgelement.cpp
source/svggeometryelement.cpp
source/svglayoutstate.cpp
source/svgpaintelement.cpp
source/svgparser.cpp
source/svgproperty.cpp
source/svgrenderstate.cpp
source/svgtextelement.cpp
)
set(lunasvg_headers
include/lunasvg.h
source/graphics.h
source/svgelement.h
source/svggeometryelement.h
source/svglayoutstate.h
source/svgpaintelement.h
source/svgparserutils.h
source/svgproperty.h
source/svgrenderstate.h
source/svgtextelement.h
)
add_library(lunasvg ${lunasvg_sources} ${lunasvg_headers})
add_library(lunasvg::lunasvg ALIAS lunasvg)
set_target_properties(lunasvg PROPERTIES
SOVERSION ${LUNASVG_VERSION_MAJOR}
CXX_VISIBILITY_PRESET hidden
CXX_STANDARD_REQUIRED ON
CXX_STANDARD 17
)
target_include_directories(lunasvg PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/source
)
target_include_directories(lunasvg PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/lunasvg>
)
target_link_libraries(lunasvg PRIVATE plutovg::plutovg)
target_compile_definitions(lunasvg PRIVATE LUNASVG_BUILD)
if(NOT BUILD_SHARED_LIBS)
target_compile_definitions(lunasvg PUBLIC LUNASVG_BUILD_STATIC)
endif()
include(CMakePackageConfigHelpers)
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/lunasvgConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/lunasvgConfig.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/lunasvg
)
write_basic_package_version_file(lunasvgConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
include(GNUInstallDirs)
install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/include/lunasvg.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lunasvg
)
install(TARGETS lunasvg
EXPORT lunasvgTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(EXPORT lunasvgTargets
FILE lunasvgTargets.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/lunasvg
NAMESPACE lunasvg::
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/lunasvgConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/lunasvgConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/lunasvg
)
export(EXPORT lunasvgTargets
FILE ${CMAKE_CURRENT_BINARY_DIR}/lunasvgTargets.cmake
NAMESPACE lunasvg::
)
option(LUNASVG_BUILD_EXAMPLES "Build examples" ON)
if(LUNASVG_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()