-
Notifications
You must be signed in to change notification settings - Fork 12
/
CMakeLists.txt
90 lines (73 loc) · 2.41 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
# CMakeLists.txt -*-CMake-*-
#
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
cmake_minimum_required(VERSION 3.27)
project(beman_optional26 VERSION 0.0.0 LANGUAGES CXX)
# Includes
include(CTest)
include(FetchContent)
set(TARGETS_EXPORT_NAME ${CMAKE_PROJECT_NAME}Targets)
option(
OPTIONAL26_ENABLE_TESTING
"Enable building tests and test infrastructure"
${PROJECT_IS_TOP_LEVEL}
)
# Build the tests if enabled via the option OPTIONAL26_ENABLE_TESTING
if(OPTIONAL26_ENABLE_TESTING)
# Fetch GoogleTest
FetchContent_Declare(
googletest
EXCLUDE_FROM_ALL
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG
e39786088138f2749d64e9e90e0f9902daa77c40 # release-1.15.0
)
FetchContent_MakeAvailable(googletest)
endif()
set(CMAKE_VERIFY_INTERFACE_HEADER_SETS ON)
# Create the library target and named header set for beman_optional26
add_library(beman_optional26 INTERFACE)
target_sources(
beman_optional26
PUBLIC FILE_SET beman_optional26_headers TYPE HEADERS BASE_DIRS include
)
if(OPTIONAL26_ENABLE_TESTING)
# Create the library target and named header set for testing beman_optional26
# and mark the set private
add_executable(beman_optional26_test)
target_sources(
beman_optional26_test
PRIVATE
FILE_SET beman_optional26_test_headers
TYPE HEADERS
BASE_DIRS src
)
add_subdirectory(src/beman/optional26/tests)
endif()
add_subdirectory(include/beman/optional26)
add_subdirectory(examples)
include(CMakePackageConfigHelpers)
# This will be used to replace @PACKAGE_cmakeModulesDir@
set(cmakeModulesDir cmake/beman)
configure_package_config_file(
cmake/Config.cmake.in
BemanOptional26Config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/beman/optional26/
PATH_VARS cmakeModulesDir
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/BemanOptional26Config.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/beman/optional26/
COMPONENT beman_optional26_development
)
# Coverage
configure_file("cmake/gcovr.cfg.in" gcovr.cfg @ONLY)
add_custom_target(
process_coverage
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Running gcovr to process coverage results"
COMMAND mkdir -p coverage
COMMAND gcovr --config gcovr.cfg .
)