@@ -12,51 +12,49 @@ include(FetchContent)
12
12
13
13
set (TARGETS_EXPORT_NAME ${CMAKE_PROJECT_NAME} Targets)
14
14
15
- # Build the tests only if enabled via the CLI flag: BUILD_TESTING.
16
- if (BUILD_TESTING)
15
+ option (OPTIONAL26_ENABLE_TESTING
16
+ "Enable building tests and test infrastructure"
17
+ ${PROJECT_IS_TOP_LEVEL} )
18
+
19
+ # Build the tests if enabled via the option OPTIONAL26_ENABLE_TESTING
20
+ if (OPTIONAL26_ENABLE_TESTING)
17
21
# Fetch GoogleTest
18
22
FetchContent_Declare(
19
23
googletest
24
+ EXCLUDE_FROM_ALL
20
25
GIT_REPOSITORY https://github.com/google/googletest.git
21
26
GIT_TAG
22
27
e39786088138f2749d64e9e90e0f9902daa77c40 # release-1.15.0
23
28
)
24
29
FetchContent_MakeAvailable(googletest)
25
30
endif ()
26
31
27
- add_subdirectory (src/beman/optional26)
28
- add_subdirectory (examples)
29
-
30
- include (GNUInstallDirs)
31
-
32
- set (INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR} /cmake)
33
-
34
- install (
35
- EXPORT ${TARGETS_EXPORT_NAME}
36
- NAMESPACE ${CMAKE_PROJECT_NAME}
37
- DESTINATION ${INSTALL_CONFIGDIR}
32
+ # Create the library target and named header set for beman_optional26
33
+ add_library (beman_optional26 STATIC )
34
+ target_sources (beman_optional26
35
+ PUBLIC
36
+ FILE_SET beman_optional26_headers TYPE HEADERS
37
+ BASE_DIRS
38
+ src
39
+ include
38
40
)
39
41
40
- include (CMakePackageConfigHelpers)
41
-
42
- write_basic_package_version_file(
43
- ${CMAKE_CURRENT_BINARY_DIR} /${CMAKE_PROJECT_NAME} ConfigVersion.cmake
44
- VERSION ${PROJECT_VERSION}
45
- COMPATIBILITY AnyNewerVersion
42
+ if (OPTIONAL26_ENABLE_TESTING)
43
+ # Create the library target and named header set for testing beman_optional26
44
+ # and mark the set private
45
+ add_executable (beman_optional26_test)
46
+ target_sources (beman_optional26_test
47
+ PRIVATE
48
+ FILE_SET beman_optional26_test_headers TYPE HEADERS
49
+ BASE_DIRS
50
+ src
46
51
)
52
+ endif ()
47
53
48
- configure_package_config_file(
49
- "cmake/Config.cmake.in"
50
- ${CMAKE_CURRENT_BINARY_DIR} /${CMAKE_PROJECT_NAME} Config.cmake
51
- INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
52
- )
54
+ add_subdirectory (src/beman/optional26)
55
+ add_subdirectory (include /beman/optional26)
53
56
54
- install (
55
- FILES
56
- ${CMAKE_CURRENT_BINARY_DIR} /${CMAKE_PROJECT_NAME} Config.cmake
57
- ${CMAKE_CURRENT_BINARY_DIR} /${CMAKE_PROJECT_NAME} ConfigVersion.cmake
58
- DESTINATION ${INSTALL_CONFIGDIR}
59
- )
57
+ add_subdirectory (examples)
60
58
61
59
# Coverage
62
60
configure_file ("cmake/gcovr.cfg.in" gcovr.cfg @ONLY)
0 commit comments