-
Notifications
You must be signed in to change notification settings - Fork 362
/
CMakeLists.txt
75 lines (59 loc) · 1.99 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
cmake_minimum_required(VERSION 3.10)
project(NanoSVG C)
# CMake needs *.c files to do something useful
configure_file(src/nanosvg.h ${CMAKE_CURRENT_BINARY_DIR}/nanosvg.c)
configure_file(src/nanosvgrast.h ${CMAKE_CURRENT_BINARY_DIR}/nanosvgrast.c)
add_library(nanosvg ${CMAKE_CURRENT_BINARY_DIR}/nanosvg.c)
find_library(MATH_LIBRARY m) # Business as usual
if(MATH_LIBRARY)
target_link_libraries(nanosvg PUBLIC ${MATH_LIBRARY})
endif()
target_include_directories(nanosvg PUBLIC $<INSTALL_INTERFACE:include/nanosvg>)
target_compile_definitions(nanosvg PRIVATE NANOSVG_IMPLEMENTATION)
# Same for nanosvgrast
add_library(nanosvgrast ${CMAKE_CURRENT_BINARY_DIR}/nanosvgrast.c)
target_link_libraries(nanosvgrast PUBLIC nanosvg)
target_include_directories(nanosvgrast PRIVATE src)
target_compile_definitions(nanosvgrast PRIVATE NANOSVGRAST_IMPLEMENTATION)
# Installation and export:
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
VERSION 1.0
COMPATIBILITY AnyNewerVersion
)
install(TARGETS nanosvg nanosvgrast
EXPORT ${PROJECT_NAME}Targets
)
export(EXPORT ${PROJECT_NAME}Targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake"
NAMESPACE ${PROJECT_NAME}::
)
set(ConfigPackageLocation lib/cmake/${PROJECT_NAME})
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION ${ConfigPackageLocation}
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
install(
FILES
src/nanosvg.h
src/nanosvgrast.h
DESTINATION
include/nanosvg
)
install(EXPORT ${PROJECT_NAME}Targets
FILE
${PROJECT_NAME}Targets.cmake
NAMESPACE
${PROJECT_NAME}::
DESTINATION
${ConfigPackageLocation}
)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION
${ConfigPackageLocation}
)