-
Notifications
You must be signed in to change notification settings - Fork 9
/
CMakeLists.txt
98 lines (75 loc) · 2.83 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
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
project(promise.hpp
VERSION "0.0.1"
DESCRIPTION "C++ asynchronous promises like a Promises/A+"
HOMEPAGE_URL "https://github.com/blackmatov/promise.hpp")
#
# LIBRARY
#
add_library(${PROJECT_NAME} INTERFACE)
add_library(promise.hpp::promise.hpp ALIAS ${PROJECT_NAME})
target_compile_features(${PROJECT_NAME} INTERFACE
cxx_std_17)
target_include_directories(${PROJECT_NAME} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/headers>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
find_package(Threads REQUIRED)
target_link_libraries(${PROJECT_NAME} INTERFACE Threads::Threads)
#
# INSTALL
#
if(PROJECT_IS_TOP_LEVEL)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
set(PROMISE_HPP_INSTALL_CONFIG_DIR
"${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
set(PROMISE_HPP_INSTALL_CONFIG_INPUT
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in")
set(PROMISE_HPP_INSTALL_GENERATED_CONFIG_CMAKE
"${CMAKE_CURRENT_BINARY_DIR}/generated/${PROJECT_NAME}-config.cmake")
set(PROMISE_HPP_INSTALL_GENERATED_CONFIG_VERSION_CMAKE
"${CMAKE_CURRENT_BINARY_DIR}/generated/${PROJECT_NAME}-config-version.cmake")
configure_package_config_file(
"${PROMISE_HPP_INSTALL_CONFIG_INPUT}"
"${PROMISE_HPP_INSTALL_GENERATED_CONFIG_CMAKE}"
INSTALL_DESTINATION "${PROMISE_HPP_INSTALL_CONFIG_DIR}"
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
write_basic_package_version_file(
"${PROMISE_HPP_INSTALL_GENERATED_CONFIG_VERSION_CMAKE}"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
ARCH_INDEPENDENT)
install(
TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}-targets
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install(
DIRECTORY headers/${PROJECT_NAME}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install(
EXPORT ${PROJECT_NAME}-targets
FILE ${PROJECT_NAME}-targets.cmake
NAMESPACE ${PROJECT_NAME}::
DESTINATION "${PROMISE_HPP_INSTALL_CONFIG_DIR}")
install(
FILES "${PROMISE_HPP_INSTALL_GENERATED_CONFIG_CMAKE}"
"${PROMISE_HPP_INSTALL_GENERATED_CONFIG_VERSION_CMAKE}"
DESTINATION "${PROMISE_HPP_INSTALL_CONFIG_DIR}")
endif()
#
# DEVELOPER
#
if(PROJECT_IS_TOP_LEVEL)
option(BUILD_WITH_COVERAGE "Build with coverage" OFF)
option(BUILD_WITH_SANITIZERS "Build with sanitizers" OFF)
enable_testing()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(EnableASan)
include(EnableGCov)
include(EnableUBSan)
add_subdirectory(vendors)
add_subdirectory(untests)
endif()