diff --git a/CMakeLists.txt b/CMakeLists.txt index b91b6370744..4b6221cfb52 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,10 +7,17 @@ if(POLICY CMP0074) cmake_policy(SET CMP0074 NEW) endif() -# Set target C++ standard +# Set target C++ standard and required compiler features set(CMAKE_CXX_STANDARD 14 CACHE STRING "The target C++ standard. PCL requires C++14 or higher.") set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) +if(CMAKE_VERSION VERSION_LESS 3.8) + # CMake did not have cxx_std_14 compile feature prior to 3.8 + # We use cxx_attribute_deprecated as a proxy because this feature is a part of c++14 standard + set(PCL_CXX_COMPILE_FEATURES cxx_attribute_deprecated) +else() + set(PCL_CXX_COMPILE_FEATURES cxx_std_14) +endif() set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "possible configurations" FORCE) diff --git a/PCLConfig.cmake.in b/PCLConfig.cmake.in index fb9065c360d..6be8c5ac990 100644 --- a/PCLConfig.cmake.in +++ b/PCLConfig.cmake.in @@ -613,6 +613,7 @@ foreach(component ${PCL_TO_FIND_COMPONENTS}) PROPERTIES INTERFACE_COMPILE_DEFINITIONS "${definitions}" INTERFACE_COMPILE_OPTIONS "${PCL_COMPILE_OPTIONS}" + INTERFACE_COMPILE_FEATURES "@PCL_CXX_COMPILE_FEATURES@" INTERFACE_INCLUDE_DIRECTORIES "${PCL_${COMPONENT}_INCLUDE_DIRS}" INTERFACE_LINK_LIBRARIES "${PCL_${COMPONENT}_LINK_LIBRARIES}" ) @@ -621,6 +622,7 @@ foreach(component ${PCL_TO_FIND_COMPONENTS}) PROPERTIES INTERFACE_COMPILE_DEFINITIONS "${definitions}" INTERFACE_COMPILE_OPTIONS "$<$:${PCL_COMPILE_OPTIONS}>" + INTERFACE_COMPILE_FEATURES "@PCL_CXX_COMPILE_FEATURES@" INTERFACE_INCLUDE_DIRECTORIES "${PCL_${COMPONENT}_INCLUDE_DIRS}" INTERFACE_LINK_LIBRARIES "${PCL_${COMPONENT}_LINK_LIBRARIES}" ) diff --git a/cmake/pcl_targets.cmake b/cmake/pcl_targets.cmake index 3729f07d2ea..4c824728ed3 100644 --- a/cmake/pcl_targets.cmake +++ b/cmake/pcl_targets.cmake @@ -192,6 +192,7 @@ endmacro() # ARGN The source files for the library. macro(PCL_ADD_LIBRARY _name _component) add_library(${_name} ${PCL_LIB_TYPE} ${ARGN}) + target_compile_features(${_name} PUBLIC ${PCL_CXX_COMPILE_FEATURES}) # must link explicitly against boost. target_link_libraries(${_name} ${Boost_LIBRARIES}) if((UNIX AND NOT ANDROID) OR MINGW)