From b87caafd9117bf7004af13fe2c806cdb5957d87c Mon Sep 17 00:00:00 2001 From: Jayesh Badwaik Date: Sun, 5 May 2019 00:23:53 +0200 Subject: [PATCH] Remove explicit setting of CXX_STANDARD for SelfTest target - The current setup tries to detect USE_CPP14/USE_CPP17 and sets the CXX_STANDARD property for the SelfTest target. This is not ideal, since CMAKE_CXX_STANDARD can be provided by the toolchain file or as command line option and should be used by the library internally correctly. Hence, the whole set of the relevant lines from `projects/CMakeLists.txt` have been removed. - The above can also cause subtle issues where the user is expecting the tests to compile with C++17 after setting CMAKE_CXX_STANDARD and then getting results of compilation with C++11 as USE_CPP17 has not been set. - The current build matrix used the above code to run the tests. So, even though the it should not required anymore to build Catch2, it was still required to send correct options to build matrix. In that respect, .travis.yml has been modified to send correct options to the build command in the new setup. --- .travis.yml | 13 +++++++++++-- projects/CMakeLists.txt | 14 -------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 345edfbb..a7dd7b07 100644 --- a/.travis.yml +++ b/.travis.yml @@ -301,10 +301,19 @@ before_script: # Regenerate single header file, so it is tested in the examples... - python scripts/generateSingleHeader.py + - | + if [[ ${CPP17} -eq 1 ]]; then + export CPP_STANDARD=17 + elif [[ ${CPP14} -eq 1 ]]; then + export CPP_STANDARD=14 + else + export CPP_STANDARD=11 + fi + # Use Debug builds for running Valgrind and building examples - - cmake -H. -BBuild-Debug -DCMAKE_BUILD_TYPE=Debug -Wdev -DUSE_CPP14=${CPP14} -DUSE_CPP17=${CPP17} -DCATCH_USE_VALGRIND=${VALGRIND} -DCATCH_BUILD_EXAMPLES=${EXAMPLES} -DCATCH_ENABLE_COVERAGE=${COVERAGE} -DCATCH_BUILD_EXTRA_TESTS=${EXTRAS} + - cmake -H. -BBuild-Debug -DCMAKE_BUILD_TYPE=Debug -Wdev -DCATCH_USE_VALGRIND=${VALGRIND} -DCATCH_BUILD_EXAMPLES=${EXAMPLES} -DCATCH_ENABLE_COVERAGE=${COVERAGE} -DCATCH_BUILD_EXTRA_TESTS=${EXTRAS} -DCMAKE_CXX_STANDARD=${CPP_STANDARD} -DCMAKE_CXX_STANDARD_REQUIRED=On -DCMAKE_CXX_EXTENSIONS=OFF # Don't bother with release build for coverage build - - cmake -H. -BBuild-Release -DCMAKE_BUILD_TYPE=Release -Wdev -DUSE_CPP14=${CPP14} -DUSE_CPP17=${CPP17} + - cmake -H. -BBuild-Release -DCMAKE_BUILD_TYPE=Release -Wdev -DCMAKE_CXX_STANDARD=${CPP_STANDARD} -DCMAKE_CXX_STANDARD_REQUIRED=On -DCMAKE_CXX_EXTENSIONS=OFF script: diff --git a/projects/CMakeLists.txt b/projects/CMakeLists.txt index 4de5c6de..c4a2b3ed 100644 --- a/projects/CMakeLists.txt +++ b/projects/CMakeLists.txt @@ -308,20 +308,6 @@ include(CTest) add_executable(SelfTest ${TEST_SOURCES} ${IMPL_SOURCES} ${REPORTER_SOURCES} ${SURROGATE_SOURCES} ${HEADERS}) target_include_directories(SelfTest PRIVATE ${HEADER_DIR}) -if(USE_CPP17) - message(STATUS "Enabling C++17") - set_property(TARGET SelfTest PROPERTY CXX_STANDARD 17) -elseif(USE_CPP14) - message(STATUS "Enabling C++14") - set_property(TARGET SelfTest PROPERTY CXX_STANDARD 14) -else() - message(STATUS "Enabling C++11") - set_property(TARGET SelfTest PROPERTY CXX_STANDARD 11) -endif() - -set_property(TARGET SelfTest PROPERTY CXX_STANDARD_REQUIRED ON) -set_property(TARGET SelfTest PROPERTY CXX_EXTENSIONS OFF) - if (CATCH_ENABLE_COVERAGE) set(ENABLE_COVERAGE ON CACHE BOOL "Enable coverage build." FORCE) find_package(codecov)