Skip to content

Commit cf46790

Browse files
authored
Make OpenMP available in downstream projects (#5744)
* 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
1 parent 956f89c commit cf46790

File tree

9 files changed

+14
-9
lines changed

9 files changed

+14
-9
lines changed

PCLConfig.cmake.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,11 @@ function(find_external_library _component _lib _is_optional)
303303
find_package(Pcap)
304304
elseif("${_lib}" STREQUAL "png")
305305
find_package(PNG)
306+
elseif("${_lib}" STREQUAL "OpenMP")
307+
find_package(OpenMP COMPONENTS CXX)
308+
# the previous find_package call sets OpenMP_CXX_LIBRARIES, but not OPENMP_LIBRARIES, which is used further down
309+
# we can link to the CMake target OpenMP::OpenMP_CXX by setting the following:
310+
set(OPENMP_LIBRARIES OpenMP::OpenMP_CXX)
306311
else()
307312
message(WARNING "${_lib} is not handled by find_external_library")
308313
endif()

features/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set(SUBSYS_DEPS common search kdtree octree filters 2d)
44

55
set(build TRUE)
66
PCL_SUBSYS_OPTION(build "${SUBSYS_NAME}" "${SUBSYS_DESC}" ON)
7-
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS})
7+
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS} OPT_DEPS OpenMP)
88

99
PCL_ADD_DOC("${SUBSYS_NAME}")
1010

filters/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set(SUBSYS_DEPS common sample_consensus search kdtree octree)
44

55
set(build TRUE)
66
PCL_SUBSYS_OPTION(build "${SUBSYS_NAME}" "${SUBSYS_DESC}" ON)
7-
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS})
7+
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS} OPT_DEPS OpenMP)
88

99
PCL_ADD_DOC("${SUBSYS_NAME}")
1010

io/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ set(SUBSYS_EXT_DEPS boost eigen)
66
set(build TRUE)
77
PCL_SUBSYS_OPTION(build "${SUBSYS_NAME}" "${SUBSYS_DESC}" ON)
88
if(WIN32)
9-
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})
9+
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})
1010
else()
11-
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})
11+
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})
1212
endif()
1313

1414
PCL_ADD_DOC("${SUBSYS_NAME}")

keypoints/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set(SUBSYS_DEPS common search kdtree octree features filters)
44

55
set(build TRUE)
66
PCL_SUBSYS_OPTION(build "${SUBSYS_NAME}" "${SUBSYS_DESC}" ON)
7-
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS})
7+
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS} OPT_DEPS OpenMP)
88

99
PCL_ADD_DOC("${SUBSYS_NAME}")
1010

registration/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set(SUBSYS_DEPS common octree kdtree search sample_consensus features filters)
44

55
set(build TRUE)
66
PCL_SUBSYS_OPTION(build "${SUBSYS_NAME}" "${SUBSYS_DESC}" ON)
7-
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS})
7+
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS} OPT_DEPS OpenMP)
88

99
PCL_ADD_DOC("${SUBSYS_NAME}")
1010

segmentation/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set(SUBSYS_DEPS common geometry search sample_consensus kdtree octree features f
44

55
set(build TRUE)
66
PCL_SUBSYS_OPTION(build "${SUBSYS_NAME}" "${SUBSYS_DESC}" ON)
7-
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS})
7+
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS} OPT_DEPS OpenMP)
88

99
PCL_ADD_DOC("${SUBSYS_NAME}")
1010

surface/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set(SUBSYS_DEPS common search kdtree octree)
44

55
set(build TRUE)
66
PCL_SUBSYS_OPTION(build "${SUBSYS_NAME}" "${SUBSYS_DESC}" ON)
7-
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS} OPT_DEPS qhull vtk)
7+
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS} OPT_DEPS qhull vtk OpenMP)
88

99
PCL_ADD_DOC("${SUBSYS_NAME}")
1010

tracking/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set(SUBSYS_DEPS common search kdtree filters octree)
44

55
set(build TRUE)
66
PCL_SUBSYS_OPTION(build "${SUBSYS_NAME}" "${SUBSYS_DESC}" ON)
7-
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS})
7+
PCL_SUBSYS_DEPEND(build NAME ${SUBSYS_NAME} DEPS ${SUBSYS_DEPS} OPT_DEPS OpenMP)
88

99
PCL_ADD_DOC("${SUBSYS_NAME}")
1010

0 commit comments

Comments
 (0)