forked from tcbrindle/span
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
59 lines (44 loc) · 1.7 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
cmake_minimum_required(VERSION 3.13...3.15)
project(span LANGUAGES CXX VERSION 0.9.0)
if(PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(SPAN_MASTER_PROJECT ON)
endif()
include(GNUInstallDirs)
add_library(span INTERFACE)
add_library(tcb::span ALIAS span)
#XXX target_sources(span INTERFACE include/tcb/span.hpp)
target_include_directories(span INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
target_compile_features(span INTERFACE cxx_std_11)
set(TCB_SPAN_TEST_CXX_STD 11 CACHE STRING "C++ standard version for testing")
option(BUILD_TESTS "Build tests" ${SPAN_MASTER_PROJECT})
option(SPAN_INSTALL "Generate the install target" ${SPAN_MASTER_PROJECT})
if(BUILD_TESTS)
enable_testing()
add_subdirectory(test)
endif()
if(SPAN_INSTALL)
include(CMakePackageConfigHelpers)
install(TARGETS span EXPORT ${PROJECT_NAME}Targets)
install(DIRECTORY include/tcb DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
set(configFile ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake)
set(versionFile ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake)
set(configInstallDestination lib/cmake/${PROJECT_NAME})
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
${configFile}
INSTALL_DESTINATION ${configInstallDestination}
)
write_basic_package_version_file(
${versionFile}
COMPATIBILITY SameMajorVersion
)
install(FILES ${configFile} ${versionFile} DESTINATION ${configInstallDestination})
install(
EXPORT ${PROJECT_NAME}Targets
NAMESPACE "tcb::"
DESTINATION ${configInstallDestination}
)
endif()