diff --git a/CMakeLists.txt b/CMakeLists.txt index 61fa5ac..bee27f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,5 +96,25 @@ foreach (project_dir ${PROJECT_DIRS}) if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/source/projects/${project_dir}/CMakeLists.txt") message("Generating: ${project_dir}") add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/projects/${project_dir}) + # C++20 everywhere: Min's posttarget pins each external to C++17 and the unit-test harness + # pins each _test target to C++17. Rather than override that per object, force C++20 on every + # target an object folder creates, in one place. + get_property(_proj_targets + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/source/projects/${project_dir} + PROPERTY BUILDSYSTEM_TARGETS) + foreach (_t ${_proj_targets}) + set_property(TARGET ${_t} PROPERTY CXX_STANDARD 20) + set_property(TARGET ${_t} PROPERTY CXX_STANDARD_REQUIRED ON) + # The min harness pins tests to C++17 because its bundled Catch calls + # std::uncaught_exception() — removed in C++20 (Apple's libc++ enforces it; libstdc++ still + # keeps it). On Apple it defines CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS, forcing that + # removed singular form. Now that tests are C++20, cancel that opt-out (our option comes + # later on the command line and wins) so Catch uses std::uncaught_exceptions(). + if (APPLE AND _t MATCHES "_test$") + target_compile_options(${_t} PRIVATE + -UCATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS + -DCATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) + endif () + endforeach () endif () endforeach () diff --git a/source/projects/mutap.aec_tilde/CMakeLists.txt b/source/projects/mutap.aec_tilde/CMakeLists.txt index 2da4d2b..ea6e034 100644 --- a/source/projects/mutap.aec_tilde/CMakeLists.txt +++ b/source/projects/mutap.aec_tilde/CMakeLists.txt @@ -27,9 +27,6 @@ target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20) include(${C74_MIN_API_DIR}/script/min-posttarget.cmake) -# min-posttarget pins CXX_STANDARD to 17; MuTap requires C++20. -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 20) - # Unit test (min-api's Catch2 harness), if the test file exists. if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}_test.cpp") include(${C74_MIN_API_DIR}/test/min-object-unittest.cmake) diff --git a/source/projects/mutap.afc_tilde/CMakeLists.txt b/source/projects/mutap.afc_tilde/CMakeLists.txt index 1bc677e..a36b3ff 100644 --- a/source/projects/mutap.afc_tilde/CMakeLists.txt +++ b/source/projects/mutap.afc_tilde/CMakeLists.txt @@ -27,9 +27,6 @@ target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20) include(${C74_MIN_API_DIR}/script/min-posttarget.cmake) -# min-posttarget pins CXX_STANDARD to 17; MuTap requires C++20. -set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 20) - # Unit test (min-api's Catch2 harness), if the test file exists. if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}_test.cpp") include(${C74_MIN_API_DIR}/test/min-object-unittest.cmake)