Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verify headers #75

Merged
merged 8 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,27 @@ jobs:
echo ${{ matrix.config.cmake_args }}
echo ${{ matrix.config.toolchain }}
rm -rf .build
cmake ${{ matrix.config.cmake_args }} -DCMAKE_TOOLCHAIN_FILE="etc/${{ matrix.config.toolchain }}-toolchain.cmake" -B .build -S .
- name: CMake Build
cmake ${{ matrix.config.cmake_args }} -DCMAKE_INSTALL_PREFIX=.install -DCMAKE_TOOLCHAIN_FILE="etc/${{ matrix.config.toolchain }}-toolchain.cmake" -B .build -S .
- name: CMake ASAN Build
run: |
set -x
cmake --build .build --config Asan --target all_verify_interface_header_sets -- -k 0
cmake --build .build --config Asan --target all -- -k 0
- name: CMake Test
- name: CMake ASAN Test
run: |
set -x
[[ ! -z "${{ matrix.config.asan_options }}" ]] && export ASAN_OPTIONS="${{ matrix.config.asan_options }}"
ctest --build-config Asan --output-on-failure --test-dir .build
- name: CMake RWDI Build
run: |
set -x
cmake --build .build --config RelWithDebInfo --target all_verify_interface_header_sets -- -k 0
cmake --build .build --config RelWithDebInfo --target all -- -k 0
- name: CMake RWDI Test
run: |
set -x
ctest --build-config RelWithDebInfo --output-on-failure --test-dir .build
- name: Install
run: |
set -x
cmake --install .build --config RelWithDebInfo --component beman_optional26_development --verbose
28 changes: 25 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ if(OPTIONAL26_ENABLE_TESTING)
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 STATIC)
add_library(beman_optional26 INTERFACE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
add_library(beman_optional26 INTERFACE)
add_library(beman.optional26 INTERFACE)

The standard says it should use . after beman. Would you like to apply these updates in your PR?

image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can fix this up as part of the PR. Need to merge in other changes in any case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be great. But feel free to speed-up/skip steps today if you need something in main for Poland.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: that will end in very strange behaviour! Normally I use something like this:

find_package(Boost CONFIG QUIET)
if(TARGET Boost::headers AND TARGET fmt::fmt)
    add_executable(to_string to_string.cpp)
    target_link_libraries(to_string fmt::fmt Boost::headers)
endif()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is creating the target that gets the named header file_set added to it? It's up here to avoid ordering problems between subdirectories.

target_sources(
beman_optional26
PUBLIC FILE_SET beman_optional26_headers TYPE HEADERS BASE_DIRS src include
PUBLIC FILE_SET beman_optional26_headers TYPE HEADERS BASE_DIRS include
)

if(OPTIONAL26_ENABLE_TESTING)
Expand All @@ -49,13 +51,33 @@ if(OPTIONAL26_ENABLE_TESTING)
TYPE HEADERS
BASE_DIRS src
)

add_subdirectory(src/beman/optional26/tests)
endif()

add_subdirectory(src/beman/optional26)
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)

Expand Down
42 changes: 35 additions & 7 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,37 +64,65 @@
{
"name": "common",
"hidden": true,
"configuration": "Asan"
"configuration": "Asan",
"targets": [
"all_verify_interface_header_sets",
"all"
]
},
{
"name": "system",
"inherits": "common",
"configurePreset": "system"
"configurePreset": "system",
"targets": [
"all_verify_interface_header_sets",
"all"
]
},
{
"name": "gcc-14",
"inherits": "common",
"configurePreset": "gcc-14"
"configurePreset": "gcc-14",
"targets": [
"all_verify_interface_header_sets",
"all"
]
},
{
"name": "gcc-13",
"inherits": "common",
"configurePreset": "gcc-13"
"configurePreset": "gcc-13",
"targets": [
"all_verify_interface_header_sets",
"all"
]
},
{
"name": "clang-19",
"inherits": "common",
"configurePreset": "clang-19"
"configurePreset": "clang-19",
"targets": [
"all_verify_interface_header_sets",
"all"
]
},
{
"name": "clang-18",
"inherits": "common",
"configurePreset": "clang-18"
"configurePreset": "clang-18",
"targets": [
"all_verify_interface_header_sets",
"all"
]
},
{
"name": "clang-17",
"inherits": "common",
"configurePreset": "clang-17"
"configurePreset": "clang-17",
"targets": [
"all_verify_interface_header_sets",
"all"
]
}
],
"testPresets": [
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ $(_build_path)/CMakeCache.txt: | $(_build_path) .gitmodules

TARGET:=all
compile: $(_build_path)/CMakeCache.txt ## Compile the project
cmake --build $(_build_path) --config $(CONFIG) --target all_verify_interface_header_sets -- -k 0
cmake --build $(_build_path) --config $(CONFIG) --target all -- -k 0

install: $(_build_path)/CMakeCache.txt compile ## Install the project
Expand Down
2 changes: 1 addition & 1 deletion cmake/Config.cmake.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# cmake/Config.cmake.in -*-makefile-*-
# cmake/Config.cmake.in -*-cmake-*-
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

@PACKAGE_INIT@
Expand Down
26 changes: 26 additions & 0 deletions include/beman/optional26/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,29 @@ target_sources(
detail/stl_interfaces/fwd.hpp
detail/stl_interfaces/iterator_interface.hpp
)

install(
TARGETS beman_optional26
FILE_SET beman_optional26_headers
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT beman_optional26_development
)

install(
TARGETS beman_optional26
EXPORT beman_optional26_export
DESTINATION
${CMAKE_INSTALL_LIBDIR}
FILE_SET beman_optional26_headers
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT beman_optional26_development
)

install(
EXPORT beman_optional26_export
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/beman/optional26/
NAMESPACE Beman::Optional26::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
NAMESPACE Beman::Optional26::
NAMESPACE beman::optional26::

?

FILE beman_optional26.cmake
EXPORT_LINK_INTERFACE_LIBRARIES
COMPONENT beman_optional26_development
)
26 changes: 0 additions & 26 deletions src/beman/optional26/CMakeLists.txt

This file was deleted.

4 changes: 0 additions & 4 deletions src/beman/optional26/detail/iterator.cpp

This file was deleted.

4 changes: 0 additions & 4 deletions src/beman/optional26/optional.cpp

This file was deleted.

2 changes: 0 additions & 2 deletions src/beman/optional26/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ target_sources(
optional_range_support.t.cpp
optional_ref.t.cpp
optional_ref_monadic.t.cpp
test_types.cpp
test_utilities.cpp
)

target_sources(
Expand Down
4 changes: 0 additions & 4 deletions src/beman/optional26/tests/test_types.cpp

This file was deleted.

4 changes: 0 additions & 4 deletions src/beman/optional26/tests/test_utilities.cpp

This file was deleted.

Loading