From a5b67e43ee0788cd2c11b930f84e292966b98dc4 Mon Sep 17 00:00:00 2001 From: Adam Kewley Date: Tue, 18 Jun 2024 14:54:26 +0200 Subject: [PATCH] Move CMAKE_CXX_EXTENSIONS and CMAKE_CXX_STANDARD_REQUIRED onto each target --- CMakeLists.txt | 2 -- apps/hellotriangle/CMakeLists.txt | 6 ++++++ apps/osc/CMakeLists.txt | 5 +++++ src/OpenSimCreator/CMakeLists.txt | 5 +++++ src/OpenSimThirdPartyPlugins/CMakeLists.txt | 5 +++++ src/oscar/CMakeLists.txt | 5 +++++ src/oscar_demos/CMakeLists.txt | 5 +++++ src/oscar_learnopengl/CMakeLists.txt | 5 +++++ tests/TestOpenSimCreator/CMakeLists.txt | 8 +++++++- tests/testoscar/CMakeLists.txt | 5 +++++ tests/testoscar_demos/CMakeLists.txt | 10 ++++++++-- tests/testoscar_learnopengl/CMakeLists.txt | 6 +++++- 12 files changed, 61 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c108b4954..56549438d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,8 +89,6 @@ if(UNIX AND NOT APPLE) set(LINUX TRUE) endif() -set(CMAKE_CXX_EXTENSIONS OFF) -set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXECUTABLE_SUFFIX ${OSC_EXECUTABLE_SUFFIX}) # note: cannot be set externally diff --git a/apps/hellotriangle/CMakeLists.txt b/apps/hellotriangle/CMakeLists.txt index 1fbc6278a..a3b95c686 100644 --- a/apps/hellotriangle/CMakeLists.txt +++ b/apps/hellotriangle/CMakeLists.txt @@ -5,6 +5,12 @@ target_link_libraries(hellotriangle PUBLIC oscar ) +set_target_properties(hellotriangle PROPERTIES + CXX_EXTENSIONS OFF + CXX_STANDARD_REQUIRED ON +) + + # for development on Windows, copy all runtime dlls to the exe directory # (because Windows doesn't have an RPATH) # diff --git a/apps/osc/CMakeLists.txt b/apps/osc/CMakeLists.txt index 0dcd1c0a1..b7cc1116d 100644 --- a/apps/osc/CMakeLists.txt +++ b/apps/osc/CMakeLists.txt @@ -63,6 +63,11 @@ target_link_options(osc PUBLIC > ) +set_target_properties(osc PROPERTIES + CXX_EXTENSIONS OFF + CXX_STANDARD_REQUIRED ON +) + # -------------- installation/packaging ------------- # diff --git a/src/OpenSimCreator/CMakeLists.txt b/src/OpenSimCreator/CMakeLists.txt index f8fbd5939..3f8b0b66e 100644 --- a/src/OpenSimCreator/CMakeLists.txt +++ b/src/OpenSimCreator/CMakeLists.txt @@ -470,3 +470,8 @@ target_compile_options(OpenSimCreator PUBLIC -Wno-array-bounds > ) + +set_target_properties(OpenSimCreator PROPERTIES + CXX_EXTENSIONS OFF + CXX_STANDARD_REQUIRED ON +) diff --git a/src/OpenSimThirdPartyPlugins/CMakeLists.txt b/src/OpenSimThirdPartyPlugins/CMakeLists.txt index 508e681ef..2d491f614 100644 --- a/src/OpenSimThirdPartyPlugins/CMakeLists.txt +++ b/src/OpenSimThirdPartyPlugins/CMakeLists.txt @@ -25,3 +25,8 @@ set_target_properties(OpenSimThirdPartyPlugins PROPERTIES ) target_compile_features(OpenSimThirdPartyPlugins PRIVATE cxx_std_14) + +set_target_properties(OpenSimThirdPartyPlugins PROPERTIES + CXX_EXTENSIONS OFF + CXX_STANDARD_REQUIRED ON +) \ No newline at end of file diff --git a/src/oscar/CMakeLists.txt b/src/oscar/CMakeLists.txt index 048c1a1a5..693e01c59 100644 --- a/src/oscar/CMakeLists.txt +++ b/src/oscar/CMakeLists.txt @@ -446,3 +446,8 @@ target_link_libraries(oscar PUBLIC tomlplusplus::tomlplusplus lunasvg::lunasvg ) + +set_target_properties(oscar PROPERTIES + CXX_EXTENSIONS OFF + CXX_STANDARD_REQUIRED ON +) \ No newline at end of file diff --git a/src/oscar_demos/CMakeLists.txt b/src/oscar_demos/CMakeLists.txt index 3a5fc4194..b622f7d2a 100644 --- a/src/oscar_demos/CMakeLists.txt +++ b/src/oscar_demos/CMakeLists.txt @@ -34,3 +34,8 @@ target_include_directories(oscar_demos PUBLIC target_link_libraries(oscar_demos PUBLIC oscar ) + +set_target_properties(oscar_demos PROPERTIES + CXX_EXTENSIONS OFF + CXX_STANDARD_REQUIRED ON +) \ No newline at end of file diff --git a/src/oscar_learnopengl/CMakeLists.txt b/src/oscar_learnopengl/CMakeLists.txt index 1ad01f385..2ed68f0a8 100644 --- a/src/oscar_learnopengl/CMakeLists.txt +++ b/src/oscar_learnopengl/CMakeLists.txt @@ -76,3 +76,8 @@ target_include_directories(oscar_learnopengl PUBLIC target_link_libraries(oscar_learnopengl PUBLIC oscar ) + +set_target_properties(oscar_learnopengl PROPERTIES + CXX_EXTENSIONS OFF + CXX_STANDARD_REQUIRED ON +) diff --git a/tests/TestOpenSimCreator/CMakeLists.txt b/tests/TestOpenSimCreator/CMakeLists.txt index b2243dfdd..5a56af83c 100644 --- a/tests/TestOpenSimCreator/CMakeLists.txt +++ b/tests/TestOpenSimCreator/CMakeLists.txt @@ -13,6 +13,7 @@ add_executable(TestOpenSimCreator Documents/ModelWarper/TestFrameWarperFactories.cpp Documents/ModelWarper/TestModelWarpDocument.cpp Documents/ModelWarper/TestPointWarperFactories.cpp + Documents/OutputExtractors/TestConstantOutputExtractor.cpp Documents/Simulation/TestForwardDynamicSimulation.cpp Documents/Simulation/TestSimulationHelpers.cpp Graphics/TestOpenSimDecorationGenerator.cpp @@ -25,7 +26,7 @@ add_executable(TestOpenSimCreator Utils/TestShapeFitters.cpp TestOpenSimCreator.cpp # entrypoint (main) - "Documents/OutputExtractors/TestConstantOutputExtractor.cpp") +) configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/TestOpenSimCreatorConfig.h.in" @@ -49,6 +50,11 @@ target_link_libraries(TestOpenSimCreator PUBLIC GTest::gtest_main ) +set_target_properties(TestOpenSimCreator PROPERTIES + CXX_EXTENSIONS OFF + CXX_STANDARD_REQUIRED ON +) + # tell CMake (+IDEs) how to find all tests if(${OSC_DISCOVER_TESTS}) gtest_discover_tests(TestOpenSimCreator) diff --git a/tests/testoscar/CMakeLists.txt b/tests/testoscar/CMakeLists.txt index 5a484f56e..6a4694976 100644 --- a/tests/testoscar/CMakeLists.txt +++ b/tests/testoscar/CMakeLists.txt @@ -129,6 +129,11 @@ target_link_libraries(testoscar PUBLIC GTest::gtest_main ) +set_target_properties(testoscar PROPERTIES + CXX_EXTENSIONS OFF + CXX_STANDARD_REQUIRED ON +) + # tell CMake (+IDEs) how to find all tests if(${OSC_DISCOVER_TESTS}) gtest_discover_tests(testoscar) diff --git a/tests/testoscar_demos/CMakeLists.txt b/tests/testoscar_demos/CMakeLists.txt index 9f0a3493e..966e1a633 100644 --- a/tests/testoscar_demos/CMakeLists.txt +++ b/tests/testoscar_demos/CMakeLists.txt @@ -22,8 +22,14 @@ target_link_libraries(testoscar_demos PUBLIC GTest::gtest_main ) -# tell CMake (+IDEs) how to find all tests -gtest_discover_tests(testoscar_demos) +set_target_properties(testoscar_demos PROPERTIES + CXX_EXTENSIONS OFF + CXX_STANDARD_REQUIRED ON +) + +if(${OSC_DISCOVER_TESTS}) + gtest_discover_tests(testoscar_demos) +endif() # for development on Windows, copy all runtime dlls to the exe directory # (because Windows doesn't have an RPATH) diff --git a/tests/testoscar_learnopengl/CMakeLists.txt b/tests/testoscar_learnopengl/CMakeLists.txt index e70bdcc9c..08273994b 100644 --- a/tests/testoscar_learnopengl/CMakeLists.txt +++ b/tests/testoscar_learnopengl/CMakeLists.txt @@ -22,7 +22,11 @@ target_link_libraries(testoscar_learnopengl PUBLIC GTest::gtest_main ) -# tell CMake (+IDEs) how to find all tests +set_target_properties(testoscar_learnopengl PROPERTIES + CXX_EXTENSIONS OFF + CXX_STANDARD_REQUIRED ON +) + if(${OSC_DISCOVER_TESTS}) gtest_discover_tests(testoscar_learnopengl) endif()