-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
72 lines (60 loc) · 2.03 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
cmake_minimum_required(VERSION 3.15)
if(PROJECT_NAME)
set(DEFERRAL_IS_SUBPROJECT TRUE)
endif ()
set(DEFERRAL_VERSION_MAJOR 1)
set(DEFERRAL_VERSION_MINOR 0)
set(DEFERRAL_VERSION_PATCH 0)
set(DEFERRAL_VERSION "${DEFERRAL_VERSION_MAJOR}.${DEFERRAL_VERSION_MINOR}.${DEFERRAL_VERSION_PATCH}")
project(deferral VERSION ${DEFERRAL_VERSION} LANGUAGES CXX)
# Create inferface library
add_library(deferral INTERFACE)
target_include_directories(deferral INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
# Testing setup
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.14.0
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
if(NOT DEFERRAL_IS_SUBPROJECT)
add_subdirectory(tests EXCLUDE_FROM_ALL)
endif()
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
set(DEFERRAL_CMAKE_CONFIG_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
VERSION "${PROJECT_VERSION}"
COMPATIBILITY "SameMajorVersion"
)
configure_package_config_file(
"${CMAKE_CURRENT_LIST_DIR}/cmake/${PROJECT_NAME}Config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION "${DEFERRAL_CMAKE_CONFIG_DESTINATION}"
)
# Targets
install(
TARGETS "deferral"
EXPORT "${PROJECT_NAME}Targets"
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)
install(
EXPORT "${PROJECT_NAME}Targets"
NAMESPACE "${PROJECT_NAME}::"
DESTINATION "${DEFERRAL_CMAKE_CONFIG_DESTINATION}"
)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
DESTINATION "${DEFERRAL_CMAKE_CONFIG_DESTINATION}"
)
# Install the header file
install(FILES include/deferral.hh DESTINATION include)