Skip to content

Commit bfc8954

Browse files
steve-downeyClausKlein
authored andcommitted
Convert to INTERFACE and verify headers
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.
1 parent 90ebb59 commit bfc8954

File tree

9 files changed

+21
-25
lines changed

9 files changed

+21
-25
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,27 @@ jobs:
8383
echo ${{ matrix.config.cmake_args }}
8484
echo ${{ matrix.config.toolchain }}
8585
rm -rf .build
86-
cmake ${{ matrix.config.cmake_args }} -DCMAKE_TOOLCHAIN_FILE="etc/${{ matrix.config.toolchain }}-toolchain.cmake" -B .build -S .
87-
- name: CMake Build
86+
cmake ${{ matrix.config.cmake_args }} -DCMAKE_INSTALL_PREFIX=.install -DCMAKE_TOOLCHAIN_FILE="etc/${{ matrix.config.toolchain }}-toolchain.cmake" -B .build -S .
87+
- name: CMake ASAN Build
8888
run: |
8989
set -x
90+
cmake --build .build --config Asan --target all_verify_interface_header_sets -- -k 0
9091
cmake --build .build --config Asan --target all -- -k 0
91-
- name: CMake Test
92+
- name: CMake ASAN Test
9293
run: |
9394
set -x
9495
[[ ! -z "${{ matrix.config.asan_options }}" ]] && export ASAN_OPTIONS="${{ matrix.config.asan_options }}"
9596
ctest --build-config Asan --output-on-failure --test-dir .build
97+
- name: CMake RWDI Build
98+
run: |
99+
set -x
100+
cmake --build .build --config RelWithDebInfo --target all_verify_interface_header_sets -- -k 0
101+
cmake --build .build --config RelWithDebInfo --target all -- -k 0
102+
- name: CMake RWDI Test
103+
run: |
104+
set -x
105+
ctest --build-config RelWithDebInfo --output-on-failure --test-dir .build
106+
- name: Install
107+
run: |
108+
set -x
109+
cmake --install .build --config RelWithDebInfo --component beman_optional26_development --verbose

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ if(OPTIONAL26_ENABLE_TESTING)
3131
FetchContent_MakeAvailable(googletest)
3232
endif()
3333

34+
set(CMAKE_VERIFY_INTERFACE_HEADER_SETS ON)
35+
3436
# Create the library target and named header set for beman_optional26
35-
add_library(beman_optional26 STATIC)
37+
add_library(beman_optional26 INTERFACE)
3638
target_sources(
3739
beman_optional26
3840
PUBLIC FILE_SET beman_optional26_headers TYPE HEADERS BASE_DIRS src include

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ $(_build_path)/CMakeCache.txt: | $(_build_path) .gitmodules
6161

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

6667
install: $(_build_path)/CMakeCache.txt compile ## Install the project

src/beman/optional26/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# src/beman/optional26/CMakeLists.txt -*-cmake-*-
22
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
33

4-
# Ensure that optional and iterator get compiled at least once
5-
target_sources(beman_optional26 PUBLIC optional.cpp detail/iterator.cpp)
6-
74
# The library is empty -- exclude it
85
install(
96
TARGETS beman_optional26

src/beman/optional26/detail/iterator.cpp

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/beman/optional26/optional.cpp

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/beman/optional26/tests/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ target_sources(
1717
optional_range_support.t.cpp
1818
optional_ref.t.cpp
1919
optional_ref_monadic.t.cpp
20-
test_types.cpp
21-
test_utilities.cpp
2220
)
2321

2422
target_sources(

src/beman/optional26/tests/test_types.cpp

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/beman/optional26/tests/test_utilities.cpp

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)