PointCloudLibrary / pcl

Point Cloud Library (PCL)
https://pointclouds.org/
Other
10.03k stars 4.62k forks source link

[compile error] Recent OpenMP not found on macOS #5635

Closed themightyoarfish closed 1 year ago

themightyoarfish commented 1 year ago

Describe the error

After brew install libomp which installs version 15.0.6, OpenMP is not found during the PCL install

To Reproduce

Result is

-- Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES)
-- Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES)
-- Could NOT find OpenMP (missing: OpenMP_C_FOUND OpenMP_CXX_FOUND C CXX)
-- Not found OpenMP

Your Environment (please complete the following information):

If PCL was compiled from source or failure in compiling PCL itself:

Possible Solution

I run into OpenMP issues with different libraries all the time, I am suspecting that cmake just doesn't handle this correctly on recent macOSes, but I'm not sure.

themightyoarfish commented 1 year ago

Actually it seems that this isn't even a PCL problem:

$ brew --prefix libomp
/opt/homebrew/opt/libomp
$ cat ../CMakeLists.txt
project(openmp-bug)
list(APPEND CMAKE_PREFIX_PATH /opt/homebrew/opt/libomp/)
find_package(OpenMP REQUIRED)
$ cmake .. 
CMake Error at /opt/homebrew/Cellar/cmake/3.24.2/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES)
Call Stack (most recent call first):
  /opt/homebrew/Cellar/cmake/3.24.2/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  /opt/homebrew/Cellar/cmake/3.24.2/share/cmake/Modules/FindOpenMP.cmake:545 (find_package_handle_standard_args)
  CMakeLists.txt:3 (find_package)

So something seems wholly broken on macos cmake.