-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
79 lines (64 loc) · 2.49 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
cmake_minimum_required(VERSION 3.10)
set(SEQ seq)
set(SEQ_VERSION 0.2.1)
project(${SEQ} VERSION ${SEQ_VERSION} LANGUAGES CXX)
include(GNUInstallDirs)
# Target configuration
add_library(${SEQ} INTERFACE)
add_library(seq::seq ALIAS ${SEQ})
target_compile_features(${SEQ} INTERFACE cxx_std_17)
target_include_directories(${SEQ} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
# Tests
enable_testing()
option(SEQ_BUILD_TESTS "Build tests" ON)
if(SEQ_BUILD_TESTS)
add_subdirectory(tests)
endif()
# Export and install targets
set(SEQ_INSTALL_CONFIGDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${SEQ}")
# Set install destinations and associate installed target files with an export
install(TARGETS ${SEQ}
EXPORT ${SEQ}-targets
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# Write build-tree targets
export(TARGETS ${SEQ}
FILE ${CMAKE_CURRENT_BINARY_DIR}/${SEQ}-targets.cmake
NAMESPACE ${SEQ}::)
# Allow find_package to locate package without installing it (find it's build-tree)
export(PACKAGE ${SEQ})
install(EXPORT ${SEQ}-targets
FILE ${SEQ}-targets.cmake
NAMESPACE ${SEQ}::
DESTINATION ${SEQ_INSTALL_CONFIGDIR})
include(CMakePackageConfigHelpers)
# Generate build-tree configuration
set(INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
configure_package_config_file("${CMAKE_CURRENT_LIST_DIR}/cmake/templates/config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${SEQ}-config.cmake"
INSTALL_DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
PATH_VARS INCLUDE_DIR
INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR})
# Generate install-tree configuration
set(INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR})
configure_package_config_file("${CMAKE_CURRENT_LIST_DIR}/cmake/templates/config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${SEQ}-config.install.cmake"
INSTALL_DESTINATION ${SEQ_INSTALL_CONFIGDIR}
PATH_VARS INCLUDE_DIR)
# Generate package version file
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${SEQ}-config-version.cmake"
VERSION ${SEQ_VERSION}
COMPATIBILITY SameMajorVersion)
# Install the install-tree configuration
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${SEQ}-config.install.cmake"
DESTINATION ${SEQ_INSTALL_CONFIGDIR}
RENAME "${SEQ}-config.cmake")
# Install package version file
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${SEQ}-config-version.cmake"
DESTINATION ${SEQ_INSTALL_CONFIGDIR})
# Install include files
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})