Skip to content

Commit

Permalink
add step to compile all headers
Browse files Browse the repository at this point in the history
  • Loading branch information
benedekkupper committed Nov 16, 2023
1 parent d617bdf commit eec84c8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/cmake-single-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Initialize Git submodules
run: git submodule update --init --recursive

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
Expand Down
21 changes: 21 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ cmake_minimum_required(VERSION 3.14)

project(hid-rp LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)

include(GNUInstallDirs)

find_package(Python 3 REQUIRED)
Expand Down Expand Up @@ -29,3 +33,20 @@ target_include_directories(${PROJECT_NAME}
$<BUILD_INTERFACE:${INCLUDES}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

# generate a source file and build it to verify syntax
file(GLOB_RECURSE HEADER_FILES "${INCLUDES}/*.hpp")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/compilation_test.cpp" "")
foreach(HEADER_FILE ${HEADER_FILES})
file(RELATIVE_PATH FILE_RELATIVE_PATH
${INCLUDES} ${HEADER_FILE}
)
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/compilation_test.cpp"
"#include \"${FILE_RELATIVE_PATH}\"\n"
)
endforeach()
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/compilation_test.cpp"
"\nint main() { return 0; }\n"
)
add_executable(${PROJECT_NAME}-verify ${CMAKE_CURRENT_BINARY_DIR}/compilation_test.cpp)
target_link_libraries(${PROJECT_NAME}-verify ${PROJECT_NAME})

0 comments on commit eec84c8

Please sign in to comment.