Skip to content

Commit

Permalink
Make interface libraries for header only.
Browse files Browse the repository at this point in the history
Added more of original func to PCLConfig.
Changed io_ply into a subsys system so its listed as modules.
  • Loading branch information
= committed Feb 8, 2024
1 parent 18e1395 commit a509c75
Show file tree
Hide file tree
Showing 9 changed files with 416 additions and 66 deletions.
3 changes: 3 additions & 0 deletions 2d/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ endif()
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include")

set(LIB_NAME "pcl_${SUBSYS_NAME}")

PCL_ADD_LIBRARY(${LIB_NAME} COMPONENT ${SUBSYS_NAME})

PCL_MAKE_PKGCONFIG(${LIB_NAME} COMPONENT ${SUBSYS_NAME} DESC ${SUBSYS_DESC} PCL_DEPS ${SUBSYS_DEPS} HEADER_ONLY)

#Install include files
Expand Down
341 changes: 334 additions & 7 deletions PCLConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,339 @@ set_and_check(PCL_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@")

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/Modules")

find_dependency(Boost)
find_dependency(Eigen3)
find_dependency(Threads)
find_dependency(OpenMP)
### ---[ 3rd party libraries
macro(find_boost)
if(PCL_ALL_IN_ONE_INSTALLER)
set(BOOST_ROOT "${PCL_ROOT}/3rdParty/Boost")
elseif(NOT BOOST_INCLUDEDIR)
set(BOOST_INCLUDEDIR "@Boost_INCLUDE_DIR@")
endif()

set(Boost_ADDITIONAL_VERSIONS
"@Boost_MAJOR_VERSION@.@Boost_MINOR_VERSION@.@Boost_SUBMINOR_VERSION@" "@Boost_MAJOR_VERSION@.@Boost_MINOR_VERSION@"
"1.84.0" "1.84" "1.83.0" "1.83" "1.82.0" "1.82" "1.81.0" "1.81" "1.80.0" "1.80"
"1.79.0" "1.79" "1.78.0" "1.78" "1.77.0" "1.77" "1.76.0" "1.76" "1.75.0" "1.75"
"1.74.0" "1.74" "1.73.0" "1.73" "1.72.0" "1.72" "1.71.0" "1.71" "1.70.0" "1.70"
"1.69.0" "1.69" "1.68.0" "1.68" "1.67.0" "1.67" "1.66.0" "1.66" "1.65.1" "1.65.0" "1.65")

find_package(Boost 1.65.0 ${QUIET_} COMPONENTS @PCLCONFIG_AVAILABLE_BOOST_MODULES@)

# Add the targets file
include("${CMAKE_CURRENT_LIST_DIR}/pcl_common.cmake")
set(BOOST_FOUND ${Boost_FOUND})
set(BOOST_INCLUDE_DIRS "${Boost_INCLUDE_DIR}")
set(BOOST_LIBRARY_DIRS "${Boost_LIBRARY_DIRS}")
set(BOOST_LIBRARIES ${Boost_LIBRARIES})
if(WIN32 AND NOT MINGW AND NOT "${BOOST_DEFINITIONS}" MATCHES "BOOST_ALL_NO_LIB")
string(APPEND BOOST_DEFINITIONS -DBOOST_ALL_NO_LIB)
endif()
endmacro()

check_required_components(PCL)
macro(find_eigen3)
if(PCL_ALL_IN_ONE_INSTALLER)
set(Eigen3_DIR "${PCL_ROOT}/3rdParty/Eigen3/share/eigen3/cmake/")
endif()
find_package(Eigen3 3.3 REQUIRED NO_MODULE)
if(NOT EIGEN3_FOUND AND Eigen3_FOUND)
set(EIGEN3_FOUND ${Eigen3_FOUND})
endif()
# In very new Eigen versions, EIGEN3_INCLUDE_DIR(S) is not defined any more, only the target:
if(TARGET Eigen3::Eigen)
set(EIGEN3_LIBRARIES Eigen3::Eigen)
endif()
endmacro()

#remove this as soon as qhull is shipped with FindQhull.cmake
macro(find_qhull)
if(PCL_ALL_IN_ONE_INSTALLER)
set(QHULL_ROOT "${PCL_ROOT}/3rdParty/Qhull")
elseif(NOT QHULL_ROOT)
get_filename_component(QHULL_ROOT "@QHULL_INCLUDE_DIRS@" PATH)
endif()

set(PCL_QHULL_REQUIRED_TYPE @PCL_QHULL_REQUIRED_TYPE@)
find_package(Qhull)
endmacro()

#remove this as soon as libopenni is shipped with FindOpenni.cmake
macro(find_openni)
if(PCL_FIND_QUIETLY)
set(OpenNI_FIND_QUIETLY TRUE)
endif()

if(NOT OPENNI_ROOT AND ("@HAVE_OPENNI@" STREQUAL "TRUE"))
set(OPENNI_INCLUDE_DIRS_HINT "@OPENNI_INCLUDE_DIRS@")
get_filename_component(OPENNI_LIBRARY_HINT "@OPENNI_LIBRARY@" PATH)
endif()

find_package(OpenNI)
endmacro()

#remove this as soon as libopenni2 is shipped with FindOpenni2.cmake
macro(find_openni2)
if(PCL_FIND_QUIETLY)
set(OpenNI2_FIND_QUIETLY TRUE)
endif()

if(NOT OPENNI2_ROOT AND ("@HAVE_OPENNI2@" STREQUAL "TRUE"))
set(OPENNI2_INCLUDE_DIRS_HINT "@OPENNI2_INCLUDE_DIRS@")
get_filename_component(OPENNI2_LIBRARY_HINT "@OPENNI2_LIBRARY@" PATH)
endif()

find_package(OpenNI2)
endmacro()

#remove this as soon as the Ensenso SDK is shipped with FindEnsenso.cmake
macro(find_ensenso)
if(PCL_FIND_QUIETLY)
set(ensenso_FIND_QUIETLY TRUE)
endif()

if(NOT ENSENSO_ROOT AND ("@HAVE_ENSENSO@" STREQUAL "TRUE"))
get_filename_component(ENSENSO_ABI_HINT "@ENSENSO_INCLUDE_DIR@" PATH)
endif()

find_package(Ensenso)
endmacro()

#remove this as soon as the davidSDK is shipped with FinddavidSDK.cmake
macro(find_davidSDK)
if(PCL_FIND_QUIETLY)
set(DAVIDSDK_FIND_QUIETLY TRUE)
endif()

if(NOT davidSDK_ROOT AND ("@HAVE_DAVIDSDK@" STREQUAL "TRUE"))
get_filename_component(DAVIDSDK_ABI_HINT @DAVIDSDK_INCLUDE_DIR@ PATH)
endif()

find_package(davidSDK)
endmacro()

macro(find_dssdk)
if(PCL_FIND_QUIETLY)
set(DSSDK_FIND_QUIETLY TRUE)
endif()
if(NOT DSSDK_DIR AND ("@HAVE_DSSDK@" STREQUAL "TRUE"))
get_filename_component(DSSDK_DIR_HINT "@DSSDK_INCLUDE_DIRS@" PATH)
endif()

find_package(DSSDK)
endmacro()

macro(find_rssdk)
if(PCL_FIND_QUIETLY)
set(RSSDK_FIND_QUIETLY TRUE)
endif()
if(NOT RSSDK_DIR AND ("@HAVE_RSSDK@" STREQUAL "TRUE"))
get_filename_component(RSSDK_DIR_HINT "@RSSDK_INCLUDE_DIRS@" PATH)
endif()

find_package(RSSDK)
endmacro()

macro(find_rssdk2)
if(PCL_ALL_IN_ONE_INSTALLER)
set(realsense2_DIR "${PCL_ROOT}/3rdParty/librealsense2/lib/cmake/realsense2" CACHE PATH "The directory containing realsense2Config.cmake")
elseif(NOT realsense2_DIR)
get_filename_component(realsense2_DIR "@REALSENSE2_INCLUDE_DIRS@" PATH)
set(realsense2_DIR "${realsense2_DIR}/lib/cmake/realsense2" CACHE PATH "The directory containing realsense2Config.cmake")
endif()
find_package(RSSDK2)
endmacro()

#remove this as soon as flann is shipped with FindFlann.cmake
macro(find_flann)
if(PCL_ALL_IN_ONE_INSTALLER)
set(FLANN_ROOT "${PCL_ROOT}/3rdParty/Flann")
elseif(NOT FLANN_ROOT)
set(FLANN_ROOT "@FLANN_ROOT@")
endif()

set(PCL_FLANN_REQUIRED_TYPE @PCL_FLANN_REQUIRED_TYPE@)
find_package(FLANN)
endmacro()

macro(find_VTK)
if(PCL_ALL_IN_ONE_INSTALLER AND NOT ANDROID)
if(EXISTS "${PCL_ROOT}/3rdParty/VTK/lib/cmake")
set(VTK_DIR "${PCL_ROOT}/3rdParty/VTK/lib/cmake/vtk-@VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@" CACHE PATH "The directory containing VTKConfig.cmake")
else()
set(VTK_DIR "${PCL_ROOT}/3rdParty/VTK/lib/vtk-@VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@" CACHE PATH "The directory containing VTKConfig.cmake")
endif()
elseif(NOT VTK_DIR AND NOT ANDROID)
set(VTK_DIR "@VTK_DIR@" CACHE PATH "The directory containing VTKConfig.cmake")
endif()
if(NOT ANDROID)
find_package(VTK ${QUIET_} COMPONENTS ${PCL_VTK_COMPONENTS})
endif()
endmacro()

macro(find_libusb)
find_package(libusb)
endmacro()

macro(find_glew)
find_package(GLEW)
endmacro()

# Finds each component external libraries if any
# The functioning is as following
# try to find _lib
# |--> _lib found ==> include the headers,
# | link to its library directories or include _lib_USE_FILE
# `--> _lib not found
# |--> _lib is optional ==> disable it (thanks to the guardians)
# | and warn
# `--> _lib is required
# |--> component is required explicitly ==> error
# `--> component is induced ==> warn and remove it
# from the list

function(find_external_library _component _lib _is_optional)
if("${_lib}" STREQUAL "boost")
find_boost()
elseif("${_lib}" STREQUAL "eigen3")
find_eigen3()
elseif("${_lib}" STREQUAL "flann")
find_flann()
elseif("${_lib}" STREQUAL "qhull")
find_qhull()
elseif("${_lib}" STREQUAL "openni")
find_openni()
elseif("${_lib}" STREQUAL "openni2")
find_openni2()
elseif("${_lib}" STREQUAL "ensenso")
find_ensenso()
elseif("${_lib}" STREQUAL "davidSDK")
find_davidSDK()
elseif("${_lib}" STREQUAL "dssdk")
find_dssdk()
elseif("${_lib}" STREQUAL "rssdk")
find_rssdk()
elseif("${_lib}" STREQUAL "rssdk2")
find_rssdk2()
elseif("${_lib}" STREQUAL "vtk")
find_VTK()
elseif("${_lib}" STREQUAL "libusb")
find_libusb()
elseif("${_lib}" STREQUAL "glew")
find_glew()
elseif("${_lib}" STREQUAL "opengl")
find_package(OpenGL)
elseif("${_lib}" STREQUAL "pcap")
find_package(Pcap)
elseif("${_lib}" STREQUAL "png")
find_package(PNG)
elseif("${_lib}" STREQUAL "OpenMP")
find_package(OpenMP COMPONENTS CXX)
# the previous find_package call sets OpenMP_CXX_LIBRARIES, but not OPENMP_LIBRARIES, which is used further down
# we can link to the CMake target OpenMP::OpenMP_CXX by setting the following:
set(OPENMP_LIBRARIES OpenMP::OpenMP_CXX)
else()
message(WARNING "${_lib} is not handled by find_external_library")
endif()

string(TOUPPER "${_component}" COMPONENT)
string(TOUPPER "${_lib}" LIB)
string(REGEX REPLACE "[.-]" "_" LIB ${LIB})

if(${LIB}_FOUND)
list(APPEND PCL_${COMPONENT}_INCLUDE_DIRS ${${LIB}_INCLUDE_DIRS})
set(PCL_${COMPONENT}_INCLUDE_DIRS ${PCL_${COMPONENT}_INCLUDE_DIRS} PARENT_SCOPE)

if(${LIB} MATCHES "VTK")
if(${${LIB}_VERSION_MAJOR} GREATER_EQUAL 9)
set(ISVTK9ORGREATER TRUE)
endif()
endif()
else()
if("${_is_optional}" STREQUAL "OPTIONAL")
list(APPEND PCL_${COMPONENT}_DEFINITIONS "-DDISABLE_${LIB}")
pcl_message("** WARNING ** ${_component} features related to ${_lib} will be disabled")
elseif("${_is_optional}" STREQUAL "REQUIRED")
if((NOT PCL_FIND_ALL) OR (PCL_FIND_ALL EQUAL 1))
pcl_report_not_found("${_component} is required but ${_lib} was not found")
elseif(PCL_FIND_ALL EQUAL 0)
# raise error and remove _component from PCL_TO_FIND_COMPONENTS
string(TOUPPER "${_component}" COMPONENT)
pcl_message("** WARNING ** ${_component} will be disabled cause ${_lib} was not found")
list(REMOVE_ITEM PCL_TO_FIND_COMPONENTS ${_component})
endif()
endif()
endif()
endfunction()

#flatten dependencies recursivity is great \o/
macro(compute_dependencies TO_FIND_COMPONENTS)
foreach(component ${${TO_FIND_COMPONENTS}})
set(pcl_component pcl_${component})
if(${pcl_component}_int_dep AND (NOT PCL_FIND_ALL))
foreach(dependency ${${pcl_component}_int_dep})
list(FIND ${TO_FIND_COMPONENTS} ${component} pos)
list(FIND ${TO_FIND_COMPONENTS} ${dependency} found)
if(found EQUAL -1)
set(pcl_dependency pcl_${dependency})
if(${pcl_dependency}_int_dep)
list(INSERT ${TO_FIND_COMPONENTS} ${pos} ${dependency})
if(pcl_${dependency}_ext_dep)
list(APPEND pcl_${component}_ext_dep ${pcl_${dependency}_ext_dep})
endif()
if(pcl_${dependency}_opt_dep)
list(APPEND pcl_${component}_opt_dep ${pcl_${dependency}_opt_dep})
endif()
compute_dependencies(${TO_FIND_COMPONENTS})
else()
list(INSERT ${TO_FIND_COMPONENTS} 0 ${dependency})
endif()
endif()
endforeach()
endif()
endforeach()
endmacro()

set(pcl_all_components @PCLCONFIG_AVAILABLE_COMPONENTS@)
list(LENGTH pcl_all_components PCL_NB_COMPONENTS)

#list each component dependencies IN PCL
@PCLCONFIG_INTERNAL_DEPENDENCIES@

#list each component external dependencies (ext means mandatory and opt means optional)
@PCLCONFIG_EXTERNAL_DEPENDENCIES@

@PCLCONFIG_OPTIONAL_DEPENDENCIES@

# VTK components required by PCL
set(PCL_VTK_COMPONENTS "@PCL_VTK_COMPONENTS@")

#check if user provided a list of components
#if no components at all or full list is given set PCL_FIND_ALL
if(PCL_FIND_COMPONENTS)
list(LENGTH PCL_FIND_COMPONENTS PCL_FIND_COMPONENTS_LENGTH)
if(PCL_FIND_COMPONENTS_LENGTH EQUAL PCL_NB_COMPONENTS)
set(PCL_TO_FIND_COMPONENTS ${pcl_all_components})
set(PCL_FIND_ALL 1)
else()
set(PCL_TO_FIND_COMPONENTS ${PCL_FIND_COMPONENTS})
endif()
else()
set(PCL_TO_FIND_COMPONENTS ${pcl_all_components})
set(PCL_FIND_ALL 1)
endif()

compute_dependencies(PCL_TO_FIND_COMPONENTS)

# compute external dependencies per component
foreach(component ${PCL_TO_FIND_COMPONENTS})
foreach(opt ${pcl_${component}_opt_dep})
find_external_library(${component} ${opt} OPTIONAL)
endforeach()
foreach(ext ${pcl_${component}_ext_dep})
find_external_library(${component} ${ext} REQUIRED)
endforeach()
endforeach()

set(PCL_LIBRARIES)
foreach(component ${PCL_TO_FIND_COMPONENTS})
# Add the targets file
include("${CMAKE_CURRENT_LIST_DIR}/pcl_${component}.cmake")
check_required_components(${component})
list(APPEND PCL_LIBRARIES "pcl::pcl_${component}")
endforeach()
Loading

0 comments on commit a509c75

Please sign in to comment.