-
Notifications
You must be signed in to change notification settings - Fork 144
/
CMakeLists.txt
86 lines (67 loc) · 2.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
cmake_minimum_required(VERSION 3.1)
project(rang
VERSION 3.2.0
LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(cmake/CMakeUtilities.cmake)
include(GNUInstallDirs)
set_verbose(RANG_INC_DIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE STRING
"Installation directory for include files, a relative path that "
"will be joined with ${CMAKE_INSTALL_PREFIX} or an absolute path.")
set(RANG_HEADERS include/rang.hpp)
add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(rang INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${RANG_INC_DIR}>
)
include(CMakePackageConfigHelpers)
set_verbose(RANG_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/rang CACHE STRING
"Installation directory for cmake files, a relative path that "
"will be joined with ${CMAKE_INSTALL_PREFIX} or an absolute "
"path.")
set(version_config ${PROJECT_BINARY_DIR}/rang-config-version.cmake)
set(project_config ${PROJECT_BINARY_DIR}/rang-config.cmake)
set(pkgconfig ${PROJECT_BINARY_DIR}/rang.pc)
set(targets_export_name rang-targets)
set_verbose(RANG_PKGCONFIG_DIR ${CMAKE_INSTALL_LIBDIR}/pkgconfig CACHE PATH
"Installation directory for pkgconfig (.pc) files, a relative "
"path that will be joined with ${CMAKE_INSTALL_PREFIX} or an "
"absolute path.")
write_basic_package_version_file(
${version_config}
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
join_paths(includedir_for_pc_file "\${prefix}" "${RANG_INC_DIR}")
# Configure the PkgConfig
configure_file(
"${PROJECT_SOURCE_DIR}/cmake/rang.pc.in"
"${pkgconfig}"
@ONLY
)
# Configuring the CMake Installer Helper
configure_package_config_file(
${PROJECT_SOURCE_DIR}/cmake/rang-config.cmake.in
${project_config}
INSTALL_DESTINATION ${RANG_CMAKE_DIR}
)
set(INSTALL_TARGETS rang)
# Install the library and headers.
install(TARGETS ${INSTALL_TARGETS} EXPORT ${targets_export_name}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
# Use a namespace because CMake provides better diagnostics for namespaced
# imported targets.
export(TARGETS ${INSTALL_TARGETS} NAMESPACE rang::
FILE ${PROJECT_BINARY_DIR}/${targets_export_name}.cmake
)
# Install version, config and target files.
install(
FILES ${project_config} ${version_config}
DESTINATION ${RANG_CMAKE_DIR}
)
install(EXPORT ${targets_export_name}
DESTINATION ${RANG_CMAKE_DIR}
NAMESPACE rang::)
install(FILES ${RANG_HEADERS} DESTINATION "${RANG_INC_DIR}")
install(FILES "${pkgconfig}" DESTINATION "${RANG_PKGCONFIG_DIR}")