commit b768df6fe2a21780f453bf7f822192011739e076 parent 41964fa3f44fdbf6feb20df528a9cdf2cc3b05ba Author: jatin <jatinchowdhury18@gmail.com> Date: Mon, 10 Jul 2023 13:58:09 -0700 Adding compile test for version macros Diffstat:
M | CMakeLists.txt | | | 4 | ++++ |
M | src/main.cc | | | 12 | ++++++++++++ |
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt @@ -60,6 +60,10 @@ if (${CLAP_BUILD_TESTS}) add_test(NAME test-clap-compile-${SUFFIX} COMMAND clap-compile-${SUFFIX}) add_dependencies(clap-tests clap-compile-${SUFFIX}) + if (${EXT} STREQUAL "cc") + target_compile_definitions(clap-compile-${SUFFIX} PRIVATE CLAP_COMPILE_TEST_CXX_VERSION=${STDCPP}) + endif() + if (${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_C_COMPILER_ID} STREQUAL "Clang") target_compile_options(clap-compile-${SUFFIX} PRIVATE -Wall -Wextra -pedantic) endif() diff --git a/src/main.cc b/src/main.cc @@ -48,6 +48,18 @@ #error CLAP_VERSION_LT is inconsistent (REVISION) #endif +#if (CLAP_COMPILE_TEST_CXX_VERSION >= 11) && ! defined(CLAP_HAS_CXX11) +#error CLAP_HAS_CXX11 is not defined correctly +#endif + +#if (CLAP_COMPILE_TEST_CXX_VERSION >= 17) && ! defined(CLAP_HAS_CXX17) +#error CLAP_HAS_CXX17 is not defined correctly +#endif + +#if (CLAP_COMPILE_TEST_CXX_VERSION >= 20) && ! defined(CLAP_HAS_CXX20) +#error CLAP_HAS_CXX20 is not defined correctly +#endif + static const CLAP_CONSTEXPR clap_version m = CLAP_VERSION; int main(int, char **) {