diff --git a/PCLConfig.cmake.in b/PCLConfig.cmake.in index 4dd18517e85..54b740d7643 100644 --- a/PCLConfig.cmake.in +++ b/PCLConfig.cmake.in @@ -704,6 +704,15 @@ foreach(component ${PCL_TO_FIND_COMPONENTS}) add_library(${pcl_component} INTERFACE IMPORTED) endif() + # Namespaced alias targets, e.g. PCL::common. An ALIAS of a non-global + # imported target requires CMake >= 3.18, so emulate it for older versions. + if(CMAKE_VERSION VERSION_LESS 3.18.0) + add_library(PCL::${component} INTERFACE IMPORTED) + target_link_libraries(PCL::${component} INTERFACE ${pcl_component}) + else() + add_library(PCL::${component} ALIAS ${pcl_component}) + endif() + foreach(def ${PCL_DEFINITIONS}) string(REPLACE " " ";" def2 ${def}) string(REGEX REPLACE "^-D" "" def3 "${def2}") @@ -749,6 +758,9 @@ endif() pcl_remove_duplicate_libraries(PCL_COMPONENTS PCL_LIBRARIES) +add_library(PCL::PCL INTERFACE IMPORTED) +target_link_libraries(PCL::PCL INTERFACE ${PCL_COMPONENTS}) + # Add 3rd party libraries, as user code might include our .HPP implementations list(APPEND PCL_LIBRARIES ${PCL_BOOST_LIBRARIES} ${PCL_OPENNI_LIBRARIES} ${PCL_OPENNI2_LIBRARIES} ${PCL_ENSENSO_LIBRARIES} ${PCL_davidSDK_LIBRARIES} ${PCL_DSSDK_LIBRARIES} ${PCL_RSSDK_LIBRARIES} ${PCL_RSSDK2_LIBRARIES} ${PCL_VTK_LIBRARIES}) if (TARGET FLANN::FLANN)