Skip to content

Commit

Permalink
Set interface compile features to cxx_std_14 on PCL targets
Browse files Browse the repository at this point in the history
For CMake older than 3.8 fall back to using cxx_attribute_deprecated
since the former did not exist yet.
  • Loading branch information
taketwo committed Dec 10, 2018
1 parent 032e1c9 commit 0b0a49a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions PCLConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
)
Expand All @@ -621,6 +622,7 @@ foreach(component ${PCL_TO_FIND_COMPONENTS})
PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "${definitions}"
INTERFACE_COMPILE_OPTIONS "$<$<COMPILE_LANGUAGE:CXX>:${PCL_COMPILE_OPTIONS}>"
INTERFACE_COMPILE_FEATURES "@PCL_CXX_COMPILE_FEATURES@"
INTERFACE_INCLUDE_DIRECTORIES "${PCL_${COMPONENT}_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${PCL_${COMPONENT}_LINK_LIBRARIES}"
)
Expand Down
1 change: 1 addition & 0 deletions cmake/pcl_targets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0b0a49a

Please sign in to comment.