From 279d7948386a96324fa628931af46aec2588de38 Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Sun, 21 Jan 2024 16:52:50 -0500 Subject: [PATCH 1/4] CLAP_STATE_CONTEXT_COMPAT is not coming Helpers referenced it; and I had if-defed it. But it seems that 1.2.0 / next will have a CONTEXT breaking change so will not define a compat. Take out the ifdef. add 11 and 14 and 17 explicit tests --- .github/workflows/pullreq.yml | 12 ++++++------ include/clap/helpers/plugin.hxx | 7 +------ 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/.github/workflows/pullreq.yml b/.github/workflows/pullreq.yml index d56b564..e069e2b 100644 --- a/.github/workflows/pullreq.yml +++ b/.github/workflows/pullreq.yml @@ -58,14 +58,14 @@ jobs: name: Linux gcc12 C++23 - os: macos-latest - cmakeargs: -GNinja + cmakeargs: -GNinja -DCLAP_HELPERS_TESTS_CXX_STANDARD=11 install_ninja: true - name: MacOS Ninja + name: MacOS Ninja C++11 - os: macos-latest - cmakeargs: -G"Xcode" + cmakeargs: -G"Xcode" -DCLAP_HELPERS_TESTS_CXX_STANDARD=14 install_ninja: false - name: MacOS Xcode + name: MacOS Xcode C++14 - os: macos-latest cmakeargs: -G"Ninja Multi-Config" -DCLAP_HELPERS_TESTS_CXX_STANDARD=20 @@ -73,9 +73,9 @@ jobs: name: MacOS Ninja Multi C++20 - os: macos-latest - cmakeargs: -G"Unix Makefiles" + cmakeargs: -G"Unix Makefiles" -DCLAP_HELPERS_TESTS_CXX_STANDARD=17 install_ninja: false - name: MacOS Unix Makefiles + name: MacOS Unix Makefiles C++17 steps: - name: Checkout code diff --git a/include/clap/helpers/plugin.hxx b/include/clap/helpers/plugin.hxx index cece034..c73aaaf 100644 --- a/include/clap/helpers/plugin.hxx +++ b/include/clap/helpers/plugin.hxx @@ -440,12 +440,7 @@ namespace clap { namespace helpers { if (!strcmp(id, CLAP_EXT_STATE) && self.implementsState()) return &_pluginState; - if ((!strcmp(id, CLAP_EXT_STATE_CONTEXT) -#ifdef CLAP_EXT_STATE_CONTEXT_COMPAT - || !strcmp(id, CLAP_EXT_STATE_CONTEXT_COMPAT) -#endif - ) && - self.implementsStateContext() && self.implementsState()) + if (!strcmp(id, CLAP_EXT_STATE_CONTEXT) && self.implementsStateContext() && self.implementsState()) return &_pluginStateContext; if ((!strcmp(id, CLAP_EXT_PRESET_LOAD) || !strcmp(id, CLAP_EXT_PRESET_LOAD_COMPAT)) && self.implementsPresetLoad()) From 2928a6f6285c89881d3f6a794dc5af15389716ec Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Sun, 21 Jan 2024 17:07:25 -0500 Subject: [PATCH 2/4] Turn on werror --- CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 671b2e3..3f666df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,8 @@ if (${CLAP_HELPERS_BUILD_TESTS}) if (NOT DEFINED CLAP_HELPERS_TESTS_CXX_STANDARD) message(STATUS "${PROJECT_NAME}: defaulting to c++11") set(CLAP_HELPERS_TESTS_CXX_STANDARD 11) + else() + message(STATUS "${PROJECT_NAME}: Using CXX Standard ${CLAP_HELPERS_TESTS_CXX_STANDARD}") endif() if ((NOT TARGET Catch2::Catch2WithMain) AND ${CLAP_HELPERS_DOWNLOAD_DEPENDENCIES}) @@ -65,10 +67,18 @@ if (${CLAP_HELPERS_BUILD_TESTS}) tests/preset-discovery-provider.cc tests/preset-discovery-metadata-receiver.cc ) + set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD ${CLAP_HELPERS_TESTS_CXX_STANDARD}) set_target_properties(${PROJECT_NAME}-tests PROPERTIES CXX_STANDARD ${CLAP_HELPERS_TESTS_CXX_STANDARD}) target_link_libraries(${PROJECT_NAME}-tests ${PROJECT_NAME} Catch2::Catch2WithMain) target_compile_definitions(${PROJECT_NAME}-tests PUBLIC -DCATCH_CONFIG_PREFIX_ALL) + if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU") + target_compile_options(${PROJECT_NAME}-tests + PRIVATE + -Werror + ) + endif() + add_custom_command(TARGET ${PROJECT_NAME}-tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E echo "Relocating $ to ${CMAKE_BINARY_DIR}" COMMAND ${CMAKE_COMMAND} -E copy "$" "${CMAKE_BINARY_DIR}" From 9f390f145893927c50ba59cf6dbe9b19b75413f4 Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Sun, 21 Jan 2024 17:10:14 -0500 Subject: [PATCH 3/4] Remove constexpr if for cxx11 restoration --- include/clap/helpers/host.hxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/clap/helpers/host.hxx b/include/clap/helpers/host.hxx index 280aa5e..13b3e33 100644 --- a/include/clap/helpers/host.hxx +++ b/include/clap/helpers/host.hxx @@ -428,7 +428,7 @@ namespace clap { namespace helpers { /////////////// template Host &Host::from(const clap_host *host) noexcept { - if constexpr (l >= CheckingLevel::Minimal) { + if (l >= CheckingLevel::Minimal) { if (!host) CLAP_HELPERS_UNLIKELY { std::cerr << "Passed an null host pointer" << std::endl; std::terminate(); @@ -436,7 +436,7 @@ namespace clap { namespace helpers { } auto self = static_cast(host->host_data); - if constexpr (l >= CheckingLevel::Minimal) { + if (l >= CheckingLevel::Minimal) { if (!self) CLAP_HELPERS_UNLIKELY { std::cerr << "Passed an invalid host pointer because the host_data is null" << std::endl; From 764507750998701be00fb727126910cb7ac58e03 Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Sun, 21 Jan 2024 17:38:30 -0500 Subject: [PATCH 4/4] Reorder workflow per review comment --- .github/workflows/pullreq.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pullreq.yml b/.github/workflows/pullreq.yml index e069e2b..c88d2c5 100644 --- a/.github/workflows/pullreq.yml +++ b/.github/workflows/pullreq.yml @@ -38,14 +38,14 @@ jobs: exe: .exe - os: ubuntu-latest - cmakeargs: -DCMAKE_CXX_COMPILER=g++-11 -DCMAKE_C_COMPILER=gcc-11 + cmakeargs: -DCMAKE_CXX_COMPILER=g++-11 -DCMAKE_C_COMPILER=gcc-11 -DCLAP_HELPERS_TESTS_CXX_STANDARD=11 install_ninja: false - name: Linux gcc11 + name: Linux gcc11 C++ 11 - os: ubuntu-latest - cmakeargs: -DCMAKE_CXX_COMPILER=g++-12 -DCMAKE_C_COMPILER=gcc-12 + cmakeargs: -DCMAKE_CXX_COMPILER=g++-12 -DCMAKE_C_COMPILER=gcc-12 -DCLAP_HELPERS_TESTS_CXX+STANDARD=17 install_ninja: false - name: Linux gcc12 + name: Linux gcc12 C++ 17 - os: ubuntu-latest cmakeargs: -DCLAP_HELPERS_TESTS_CXX_STANDARD=20 -DCMAKE_CXX_COMPILER=g++-12 -DCMAKE_C_COMPILER=gcc-12 @@ -67,16 +67,16 @@ jobs: install_ninja: false name: MacOS Xcode C++14 - - os: macos-latest - cmakeargs: -G"Ninja Multi-Config" -DCLAP_HELPERS_TESTS_CXX_STANDARD=20 - install_ninja: true - name: MacOS Ninja Multi C++20 - - os: macos-latest cmakeargs: -G"Unix Makefiles" -DCLAP_HELPERS_TESTS_CXX_STANDARD=17 install_ninja: false name: MacOS Unix Makefiles C++17 + - os: macos-latest + cmakeargs: -G"Ninja Multi-Config" -DCLAP_HELPERS_TESTS_CXX_STANDARD=20 + install_ninja: true + name: MacOS Ninja Multi C++20 + steps: - name: Checkout code uses: actions/checkout@v2