Skip to content

Commit 91a487c

Browse files
committed
Test headers are kosher
1 parent 0227b7a commit 91a487c

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

.github/workflows/build_linux.yml

+21
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,27 @@ jobs:
4343
cmake --build "${{ github.workspace }}/cmake-build" --config "Debug" --target install
4444
cmake --build "${{ github.workspace }}/cmake-build" --config "Release" --target install
4545
46+
# appended to the end of the build-shared job steps:
47+
- name: Check Installed Headers Compile Cleanly
48+
run: |
49+
mkdir -p header-check
50+
cd header-check
51+
cmake -S . -B build -DCMAKE_C_STANDARD=99 -DMYAPI_INCLUDE_DIR="${{ github.workspace }}/install/include" <<EOF
52+
cmake_minimum_required(VERSION 3.15)
53+
project(HeaderCheck C)
54+
55+
file(GLOB PUBLIC_HEADERS "\${MYAPI_INCLUDE_DIR}/*.h")
56+
57+
foreach(header IN LISTS PUBLIC_HEADERS)
58+
get_filename_component(header_file "\${header}" NAME)
59+
set(test_source "\${CMAKE_BINARY_DIR}/check_\${header_file}.c")
60+
file(WRITE "\${test_source}" "#include <\${header_file}>\nint main(void) { return 0; }\n")
61+
add_executable("check_\${header_file}" "\${test_source}")
62+
target_include_directories("check_\${header_file}" PRIVATE "\${MYAPI_INCLUDE_DIR}")
63+
endforeach()
64+
EOF
65+
cmake --build build --parallel
66+
4667
- name: Upload Artifact
4768
uses: actions/upload-artifact@v4
4869
with:

0 commit comments

Comments
 (0)