From 6de20dab9cce8c6cafb93f6ff285aeab7cb93a95 Mon Sep 17 00:00:00 2001 From: Benedek Kupper Date: Thu, 16 Nov 2023 09:21:19 +0100 Subject: [PATCH] add step to compile all headers --- .github/workflows/cmake-single-platform.yml | 3 +++ CMakeLists.txt | 21 +++++++++++++++++++++ hid-rp/hid/rdf/descriptor_view.hpp | 2 +- hid-rp/hid/rdf/parser.hpp | 1 - 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cmake-single-platform.yml b/.github/workflows/cmake-single-platform.yml index f522b05..2a93bde 100644 --- a/.github/workflows/cmake-single-platform.yml +++ b/.github/workflows/cmake-single-platform.yml @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 4194c33..b0b8f28 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -29,3 +33,20 @@ target_include_directories(${PROJECT_NAME} $ $ ) + +# 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}) diff --git a/hid-rp/hid/rdf/descriptor_view.hpp b/hid-rp/hid/rdf/descriptor_view.hpp index 7c1ef4e..fd48ca6 100644 --- a/hid-rp/hid/rdf/descriptor_view.hpp +++ b/hid-rp/hid/rdf/descriptor_view.hpp @@ -12,7 +12,7 @@ #define __HID_RDF_DESCRIPTOR_VIEW_HPP_ #include - +#include #include "hid/rdf/item.hpp" namespace hid::rdf diff --git a/hid-rp/hid/rdf/parser.hpp b/hid-rp/hid/rdf/parser.hpp index 4a91d13..d050b12 100644 --- a/hid-rp/hid/rdf/parser.hpp +++ b/hid-rp/hid/rdf/parser.hpp @@ -11,7 +11,6 @@ #ifndef __HID_RDF_PARSER_HPP_ #define __HID_RDF_PARSER_HPP_ -#include #include "hid/usage.hpp" #include "hid/rdf/descriptor_view.hpp"