Commit a182b3a6 authored by Robert Maynard's avatar Robert Maynard

Enable C++11 by using CMake target_compile_features

parent 4958cf97
......@@ -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@")
......
......@@ -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()
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment