Skip to content

Commit

Permalink
Convert to INTERFACE and verify headers
Browse files Browse the repository at this point in the history
Convert to an interface library and use verify headers to test that headers are
self-contained and compile correctly by themselves. Test install at end of CI
and run both Asan and RWDI builds.
  • Loading branch information
steve-downey committed Nov 10, 2024
1 parent 9847480 commit c1dd562
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 25 deletions.
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 -DCMAKE_INSTALL_PREFIX=.install --install .build --config RelWithDebInfo --component beman_optional26_development --verbose
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ 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)
target_sources(
beman_optional26
PUBLIC FILE_SET beman_optional26_headers TYPE HEADERS BASE_DIRS src include
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
3 changes: 0 additions & 3 deletions src/beman/optional26/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# src/beman/optional26/CMakeLists.txt -*-cmake-*-
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# Ensure that optional and iterator get compiled at least once
target_sources(beman_optional26 PUBLIC optional.cpp detail/iterator.cpp)

# The library is empty -- exclude it
install(
TARGETS beman_optional26
Expand Down
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.

0 comments on commit c1dd562

Please sign in to comment.