Skip to content

Commit

Permalink
CLAP_STATE_CONTEXT_COMPAT; C++11 restored
Browse files Browse the repository at this point in the history
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.

Remove a constexpr if which broke C++11

Add C++ 11, 14, 17, 20 and 23 to the CI test

Make sure the CI tests run with `Werror` on gcc/clang to avoid 17-isms sneaking in unannounced.
  • Loading branch information
baconpaul authored Jan 21, 2024
1 parent 62824ef commit 0a5d34d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 21 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/pullreq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -58,25 +58,25 @@ 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"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

- os: macos-latest
cmakeargs: -G"Unix Makefiles"
install_ninja: false
name: MacOS Unix Makefiles

steps:
- name: Checkout code
uses: actions/checkout@v2
Expand Down
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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 $<TARGET_FILE:${PROJECT_NAME}-tests> to ${CMAKE_BINARY_DIR}"
COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE:${PROJECT_NAME}-tests>" "${CMAKE_BINARY_DIR}"
Expand Down
4 changes: 2 additions & 2 deletions include/clap/helpers/host.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -428,15 +428,15 @@ namespace clap { namespace helpers {
///////////////
template <MisbehaviourHandler h, CheckingLevel l>
Host<h, l> &Host<h, l>::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();
}
}

auto self = static_cast<Host *>(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;
Expand Down
7 changes: 1 addition & 6 deletions include/clap/helpers/plugin.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 0a5d34d

Please sign in to comment.