Skip to content

Commit 426ca35

Browse files
committed
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 9847480 commit 426ca35

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
@@ -82,13 +82,27 @@ jobs:
8282
echo ${{ matrix.config.cmake_args }}
8383
echo ${{ matrix.config.toolchain }}
8484
rm -rf .build
85-
cmake ${{ matrix.config.cmake_args }} -DCMAKE_TOOLCHAIN_FILE="etc/${{ matrix.config.toolchain }}-toolchain.cmake" -B .build -S .
86-
- name: CMake Build
85+
cmake ${{ matrix.config.cmake_args }} -DCMAKE_INSTALL_PREFIX=.install -DCMAKE_TOOLCHAIN_FILE="etc/${{ matrix.config.toolchain }}-toolchain.cmake" -B .build -S .
86+
- name: CMake ASAN Build
8787
run: |
8888
set -x
89+
cmake --build .build --config Asan --target all_verify_interface_header_sets -- -k 0
8990
cmake --build .build --config Asan --target all -- -k 0
90-
- name: CMake Test
91+
- name: CMake ASAN Test
9192
run: |
9293
set -x
9394
[[ ! -z "${{ matrix.config.asan_options }}" ]] && export ASAN_OPTIONS="${{ matrix.config.asan_options }}"
9495
ctest --build-config Asan --output-on-failure --test-dir .build
96+
- name: CMake RWDI Build
97+
run: |
98+
set -x
99+
cmake --build .build --config RelWithDebInfo --target all_verify_interface_header_sets -- -k 0
100+
cmake --build .build --config RelWithDebInfo --target all -- -k 0
101+
- name: CMake RWDI Test
102+
run: |
103+
set -x
104+
ctest --build-config RelWithDebInfo --output-on-failure --test-dir .build
105+
- name: Install
106+
run: |
107+
set -x
108+
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)