diff --git a/CMake/VTKConfig.cmake.in b/CMake/VTKConfig.cmake.in index 2e6cc53eb54c4db4e260bf9dd535c040191339c1..cbbfd6d343746e4646f97e9258b32d9e9c11174c 100644 --- a/CMake/VTKConfig.cmake.in +++ b/CMake/VTKConfig.cmake.in @@ -12,12 +12,6 @@ if (CMAKE_VERSION VERSION_LESS "3.3") message(FATAL_ERROR "VTK now requires CMake 3.3 or newer") endif() -set(VTK_USE_CXX11_FEATURES @VTK_USE_CXX11_FEATURES@) -if (VTK_USE_CXX11_FEATURES) - set(CMAKE_CXX_STANDARD 11) - set(CMAKE_CXX_STANDARD_REQUIRED 11) -endif() - # The C and C++ flags added by VTK to the cmake-configured flags. SET(VTK_REQUIRED_C_FLAGS "@VTK_REQUIRED_C_FLAGS@") SET(VTK_REQUIRED_CXX_FLAGS "@VTK_REQUIRED_CXX_FLAGS@") diff --git a/CMake/vtkModuleMacros.cmake b/CMake/vtkModuleMacros.cmake index a43af47c16c97aa178ed52897947311ec942dada..7a45572b6fc54e9e7e79a3821fe292d4a51118e7 100644 --- a/CMake/vtkModuleMacros.cmake +++ b/CMake/vtkModuleMacros.cmake @@ -536,6 +536,10 @@ endfunction() function(vtk_add_library name) add_library(${name} ${ARGN} ${headers}) + # We use compile features to specify that VTK requires C++11 + # But at the same time don't have to be concerned about + # polluting non-VTK targets with that requirement + target_compile_features(${name} PUBLIC cxx_nullptr) if(NOT ARGV1 STREQUAL OBJECT) vtk_target(${name}) endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index 774ed87e1a6d82fde6bca484f305003b1edc0fb4..63e9f93d4911fe1f856040ef1c3c684abbd206c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,13 +13,12 @@ endif() project(VTK) -option(VTK_USE_CXX11_FEATURES "Build VTK using C++11 features (if available)" - OFF) -if (VTK_USE_CXX11_FEATURES) - set(CMAKE_CXX_STANDARD 11) - set(CMAKE_CXX_STANDARD_REQUIRED True) - set(CMAKE_CXX_EXTENSIONS False) -endif() +# Make sure we have C++11 enabled. +# Needed to make sure libraries and executables not built +# through the module system use C++11 +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) +set(CMAKE_CXX_EXTENSIONS False) # Objective-C++ compile flags. # CMake has no equivalent of CMAKE_CXX_FLAGS for Objective-C++ (bug #4756)