Skip to content

Commit

Permalink
Make OpenMP available in downstream projects (#5744)
Browse files Browse the repository at this point in the history
* Make OpenMP available in downstream projects
Previously, if a downstream project used PCL_NO_PRECOMPILE or if it used a PCL class which includes OpenMP code, but PCL does not make an instantiation of that class, OpenMP was not available.
In other words, when PCL code using OpenMP was compiled when building PCL, OpenMP was available. However when PCL code using OpenMP was compiled in the downstream/user project (e.g. in the two mentioned cases), OpenMP was not available.
The fix is to search for OpenMP again in PCLConfig.cmake

* OpenMP as dep for more modules
  • Loading branch information
mvieth committed Jun 12, 2023
1 parent 956f89c commit cf46790
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 9 deletions.
5 changes: 5 additions & 0 deletions PCLConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ function(find_external_library _component _lib _is_optional)
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()
Expand Down
2 changes: 1 addition & 1 deletion features/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set(SUBSYS_DEPS common search kdtree octree filters 2d)

set(build TRUE)
PCL_SUBSYS_OPTION(build "${SUBSYS_NAME}" "${SUBSYS_DESC}" ON)
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS})
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS} OPT_DEPS OpenMP)

PCL_ADD_DOC("${SUBSYS_NAME}")

Expand Down
2 changes: 1 addition & 1 deletion filters/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set(SUBSYS_DEPS common sample_consensus search kdtree octree)

set(build TRUE)
PCL_SUBSYS_OPTION(build "${SUBSYS_NAME}" "${SUBSYS_DESC}" ON)
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS})
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS} OPT_DEPS OpenMP)

PCL_ADD_DOC("${SUBSYS_NAME}")

Expand Down
4 changes: 2 additions & 2 deletions io/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ set(SUBSYS_EXT_DEPS boost eigen)
set(build TRUE)
PCL_SUBSYS_OPTION(build "${SUBSYS_NAME}" "${SUBSYS_DESC}" ON)
if(WIN32)
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS} OPT_DEPS openni openni2 ensenso davidSDK dssdk rssdk rssdk2 pcap png vtk EXT_DEPS ${SUBSYS_EXT_DEPS})
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS} OPT_DEPS openni openni2 ensenso davidSDK dssdk rssdk rssdk2 pcap png vtk OpenMP EXT_DEPS ${SUBSYS_EXT_DEPS})
else()
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS} OPT_DEPS openni openni2 ensenso davidSDK dssdk pcap png vtk libusb EXT_DEPS ${SUBSYS_EXT_DEPS})
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS} OPT_DEPS openni openni2 ensenso davidSDK dssdk pcap png vtk libusb OpenMP EXT_DEPS ${SUBSYS_EXT_DEPS})
endif()

PCL_ADD_DOC("${SUBSYS_NAME}")
Expand Down
2 changes: 1 addition & 1 deletion keypoints/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set(SUBSYS_DEPS common search kdtree octree features filters)

set(build TRUE)
PCL_SUBSYS_OPTION(build "${SUBSYS_NAME}" "${SUBSYS_DESC}" ON)
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS})
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS} OPT_DEPS OpenMP)

PCL_ADD_DOC("${SUBSYS_NAME}")

Expand Down
2 changes: 1 addition & 1 deletion registration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set(SUBSYS_DEPS common octree kdtree search sample_consensus features filters)

set(build TRUE)
PCL_SUBSYS_OPTION(build "${SUBSYS_NAME}" "${SUBSYS_DESC}" ON)
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS})
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS} OPT_DEPS OpenMP)

PCL_ADD_DOC("${SUBSYS_NAME}")

Expand Down
2 changes: 1 addition & 1 deletion segmentation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set(SUBSYS_DEPS common geometry search sample_consensus kdtree octree features f

set(build TRUE)
PCL_SUBSYS_OPTION(build "${SUBSYS_NAME}" "${SUBSYS_DESC}" ON)
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS})
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS} OPT_DEPS OpenMP)

PCL_ADD_DOC("${SUBSYS_NAME}")

Expand Down
2 changes: 1 addition & 1 deletion surface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set(SUBSYS_DEPS common search kdtree octree)

set(build TRUE)
PCL_SUBSYS_OPTION(build "${SUBSYS_NAME}" "${SUBSYS_DESC}" ON)
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS} OPT_DEPS qhull vtk)
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS} OPT_DEPS qhull vtk OpenMP)

PCL_ADD_DOC("${SUBSYS_NAME}")

Expand Down
2 changes: 1 addition & 1 deletion tracking/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set(SUBSYS_DEPS common search kdtree filters octree)

set(build TRUE)
PCL_SUBSYS_OPTION(build "${SUBSYS_NAME}" "${SUBSYS_DESC}" ON)
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS})
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS} OPT_DEPS OpenMP)

PCL_ADD_DOC("${SUBSYS_NAME}")

Expand Down

0 comments on commit cf46790

Please sign in to comment.