diff --git a/CMakeLists.txt b/CMakeLists.txt index 9caacfb3..0f34f546 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,17 @@ cmake_minimum_required(VERSION 3.12) project(OpenSubdiv) +# Set C++ standard requirements, allowing overrides +if (NOT DEFINED CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 14) +endif() +if (NOT DEFINED CMAKE_CXX_STANDARD_REQUIRED) + set(CMAKE_CXX_STANDARD_REQUIRED ON) +endif() +if (NOT DEFINED CMAKE_CXX_EXTENSIONS) + set(CMAKE_CXX_EXTENSIONS OFF) +endif() + # Turn on folder support set_property(GLOBAL PROPERTY USE_FOLDERS ON) @@ -446,12 +457,6 @@ endif() if( METAL_FOUND AND NOT NO_METAL) set(OSD_GPU TRUE) - if (CMAKE_COMPILER_IS_CLANGCC) - # When building with Metal support enabled, we need to explicitly - # request that the C++ code be compiled with C++11 since some example - # code for Metal relies on functionality only available in C++11. - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - endif() endif() if( OPENGL_FOUND AND NOT NO_OPENGL) diff --git a/examples/common/CMakeLists.txt b/examples/common/CMakeLists.txt index 079c56c4..cf8b9f46 100644 --- a/examples/common/CMakeLists.txt +++ b/examples/common/CMakeLists.txt @@ -157,8 +157,6 @@ if(METAL_FOUND) mtlHud.h ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") - add_library(examples_common_mtl_obj OBJECT ${EXAMPLES_COMMON_SOURCE_FILES} diff --git a/examples/mtlPtexViewer/CMakeLists.txt b/examples/mtlPtexViewer/CMakeLists.txt index f8e51ff7..28f19572 100644 --- a/examples/mtlPtexViewer/CMakeLists.txt +++ b/examples/mtlPtexViewer/CMakeLists.txt @@ -108,10 +108,6 @@ if(IOS) ) endif() - - -set_property (TARGET mtlPtexViewer PROPERTY CXX_STANDARD 14) - target_link_libraries(mtlPtexViewer ${PLATFORM_LIBRARIES} ) diff --git a/examples/mtlViewer/CMakeLists.txt b/examples/mtlViewer/CMakeLists.txt index c1445954..6c67954b 100644 --- a/examples/mtlViewer/CMakeLists.txt +++ b/examples/mtlViewer/CMakeLists.txt @@ -104,10 +104,6 @@ if(IOS) ) endif() - - -set_property (TARGET mtlViewer PROPERTY CXX_STANDARD 14) - target_link_libraries(mtlViewer ${PLATFORM_LIBRARIES} ) diff --git a/opensubdiv/CMakeLists.txt b/opensubdiv/CMakeLists.txt index 01034860..4f3e3f3e 100644 --- a/opensubdiv/CMakeLists.txt +++ b/opensubdiv/CMakeLists.txt @@ -80,7 +80,6 @@ if (NOT NO_LIB) list(APPEND PLATFORM_GPU_LIBRARIES ${METAL_LIBRARIES} ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") endif() if ( OPENCL_FOUND )