-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
73 lines (60 loc) · 1.96 KB
/
CMakeLists.txt
File metadata and controls
73 lines (60 loc) · 1.96 KB
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
# CMakeLists.txt -*-CMake-*-
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
cmake_minimum_required(VERSION 3.27...4.3)
project(beman.optional VERSION 1.0.0 LANGUAGES CXX)
# Includes
include(CTest)
include(FetchContent)
set(TARGETS_EXPORT_NAME ${PROJECT_NAME}Targets)
option(
OPTIONAL_ENABLE_TESTING
"Enable building tests and test infrastructure"
${PROJECT_IS_TOP_LEVEL}
)
set(CMAKE_VERIFY_INTERFACE_HEADER_SETS ON)
# Create the library target and named header set for beman.optional
add_library(beman.optional INTERFACE)
target_sources(
beman.optional
PUBLIC FILE_SET beman_optional_headers TYPE HEADERS BASE_DIRS include
)
if(OPTIONAL_ENABLE_TESTING)
find_package(GTest QUIET)
if(GTest_FOUND)
# Create the library target and named header set for testing beman.optional
# and mark the set private
add_executable(beman.optional.test)
target_sources(
beman.optional.test
PRIVATE
FILE_SET beman_optional_test_headers
TYPE HEADERS
BASE_DIRS tests
)
# Tests
add_subdirectory(tests/beman/optional)
include(GoogleTest)
gtest_discover_tests(beman.optional.test)
else()
message(
WARNING
"
No provider for GTest. Unable to build tests.
Consider using CMAKE_PROJECT_TOP_LEVEL_INCLUDES=./cmake/use-fetch-content.cmake as documented in the README.md
"
)
endif()
endif()
add_subdirectory(include/beman/optional)
add_subdirectory(examples)
include(infra/cmake/beman-install-library.cmake)
beman_install_library(beman.optional TARGETS beman.optional)
# 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 .
)