Skip to content

Commit

Permalink
Enable C++11 by using CMake target_compile_features
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Maynard committed Jan 16, 2017
1 parent 4958cf9 commit a182b3a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
6 changes: 0 additions & 6 deletions CMake/VTKConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -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@")
Expand Down
4 changes: 4 additions & 0 deletions CMake/vtkModuleMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
13 changes: 6 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a182b3a

Please sign in to comment.