Skip to content

Commit b965217

Browse files
Switch to filesets and enable header verification (#21)
Removes target_include_directories / install(FILES) in favor of target_sources(FILE_SET HEADERS) Also fixes a number of outstanding issues with the existing CML: * [CMAKE.PASSIVE_PROJECTS] * [CMAKE.CONFIG] Co-authored-by: Patrick Roberts <[email protected]>
1 parent 7b7fde2 commit b965217

File tree

2 files changed

+43
-24
lines changed

2 files changed

+43
-24
lines changed

CMakeLists.txt

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,20 @@ project(
1212
# [CMAKE.SKIP_TESTS]
1313
option(
1414
BEMAN_ANY_VIEW_BUILD_TESTS
15-
"Enable building tests and test infrastructure. Default: ON. Values: { ON, OFF }."
15+
"Enable building tests and test infrastructure. Default: ${PROJECT_IS_TOP_LEVEL}. Values: { ON, OFF }."
1616
${PROJECT_IS_TOP_LEVEL}
1717
)
1818

1919
# [CMAKE.SKIP_EXAMPLES]
2020
option(
2121
BEMAN_ANY_VIEW_BUILD_EXAMPLES
22-
"Enable building examples. Default: ON. Values: {ON, OFF}."
22+
"Enable building examples. Default: ${PROJECT_IS_TOP_LEVEL}. Values: {ON, OFF}."
23+
${PROJECT_IS_TOP_LEVEL}
24+
)
25+
26+
option(
27+
BEMAN_ANY_VIEW_INSTALL_CONFIG_FILE_PACKAGE
28+
"Enable creating and installing a CMake config-file package. Default: ${PROJECT_IS_TOP_LEVEL}. Values: { ON, OFF }."
2329
${PROJECT_IS_TOP_LEVEL}
2430
)
2531

@@ -44,37 +50,49 @@ configure_file(
4450
@ONLY
4551
)
4652

47-
set(CMAKE_CXX_EXTENSIONS OFF)
48-
49-
include(FetchContent)
50-
include(GNUInstallDirs)
51-
5253
# [CMAKE.LIBRARY_NAME]
5354
add_library(beman.any_view INTERFACE)
5455
# [CMAKE.LIBRARY_ALIAS]
5556
add_library(beman::any_view ALIAS beman.any_view)
56-
target_include_directories(
57+
58+
set_target_properties(
5759
beman.any_view
58-
INTERFACE
59-
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
60-
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
61-
$<INSTALL_INTERFACE:include>
60+
PROPERTIES VERIFY_INTERFACE_HEADER_SETS ON EXPORT_NAME any_view
6261
)
6362

64-
install(
65-
TARGETS beman.any_view
66-
EXPORT ${TARGETS_EXPORT_NAME}
67-
DESTINATION
68-
$<$<CONFIG:Debug>:debug/>${CMAKE_INSTALL_LIBDIR}
63+
target_sources(
64+
beman.any_view
65+
PUBLIC
66+
FILE_SET HEADERS
67+
BASE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/include include
68+
FILES
69+
${CMAKE_CURRENT_BINARY_DIR}/include/beman/any_view/config.hpp
70+
include/beman/any_view/detail/any_iterator.hpp
71+
include/beman/any_view/detail/concepts.hpp
72+
include/beman/any_view/detail/intrusive_small_ptr.hpp
73+
include/beman/any_view/detail/iterator_adaptor.hpp
74+
include/beman/any_view/detail/iterator_interface.hpp
75+
include/beman/any_view/detail/type_traits.hpp
76+
include/beman/any_view/detail/utility.hpp
77+
include/beman/any_view/detail/view_adaptor.hpp
78+
include/beman/any_view/detail/view_interface.hpp
79+
include/beman/any_view/any_view_options.hpp
80+
include/beman/any_view/any_view.hpp
81+
include/beman/any_view/concepts.hpp
6982
)
7083

71-
install(
72-
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
73-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_PROJECT_NAME}
74-
FILES_MATCHING
75-
PATTERN "${CMAKE_CURRENT_SOURCE_DIR}/include/beman/any_view/*.hpp"
76-
PATTERN "${CMAKE_CURRENT_BINARY_DIR}/include/beman/any_view/*.hpp"
77-
)
84+
include(GNUInstallDirs)
85+
86+
install(TARGETS beman.any_view EXPORT beman.any_view-targets FILE_SET HEADERS)
87+
88+
if(BEMAN_ANY_VIEW_INSTALL_CONFIG_FILE_PACKAGE)
89+
install(
90+
EXPORT beman.any_view-targets
91+
FILE beman.any_view-config.cmake
92+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/beman.any_view"
93+
NAMESPACE beman::
94+
)
95+
endif()
7896

7997
function(beman_add_executable)
8098
set(options)

tests/beman/any_view/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
22

3+
include(FetchContent)
34
# Fetch Benchmark
45
FetchContent_Declare(
56
benchmark

0 commit comments

Comments
 (0)