FindOpenMP fails to set flags when used with vcpkg toolchain file
I have packaged libomp
using vcpkg. When I pass the vcpkg.cmake toolchain file to the build and watch find package debug output, the headers and library are found but the OpenMP flags aren't set and the build fails.
% cmake -G Xcode -DCMAKE_TOOLCHAIN_FILE=~/Workspace/local/vcpkg-openmp-example/vcpkg/scripts/buildsystems/vcpkg.cmake ..
-- The CXX compiler identification is AppleClang 15.0.0.15000040
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Debug Log at /usr/local/Cellar/cmake/3.27.6/share/cmake/Modules/FindOpenMP.cmake:305 (find_library):
find_library(OpenMP_libomp_LIBRARY) added replacement path
/Users/michaeltryby/Workspace/local/vcpkg-openmp-example/vcpkg/installed/x64-osx/debug/lib/
to PATH_SUFFIXES for architecture suffix '64'
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.27.6/share/cmake/Modules/FindOpenMP.cmake:483 (_OPENMP_GET_FLAGS)
/Users/michaeltryby/Workspace/local/vcpkg-openmp-example/vcpkg/scripts/buildsystems/vcpkg.cmake:859 (_find_package)
CMakeLists.txt:34 (find_package)
CMake Debug Log at /usr/local/Cellar/cmake/3.27.6/share/cmake/Modules/FindOpenMP.cmake:305 (find_library):
find_library(OpenMP_libomp_LIBRARY) removed original suffix
/Users/michaeltryby/Workspace/local/vcpkg-openmp-example/vcpkg/installed/x64-osx/debug/lib/
from PATH_SUFFIXES while adding architecture paths for suffix '64'
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.27.6/share/cmake/Modules/FindOpenMP.cmake:483 (_OPENMP_GET_FLAGS)
/Users/michaeltryby/Workspace/local/vcpkg-openmp-example/vcpkg/scripts/buildsystems/vcpkg.cmake:859 (_find_package)
CMakeLists.txt:34 (find_package)
...
CMake Debug Log at /usr/local/Cellar/cmake/3.27.6/share/cmake/Modules/FindOpenMP.cmake:305 (find_library):
find_library called with the following settings:
VAR: OpenMP_libomp_LIBRARY
NAMES: "omp"
"gomp"
"iomp5"
Documentation: Path to a library.
Framework
Only Search Frameworks: 0
Search Frameworks Last: 1
Search Frameworks First: 0
AppBundle
Only Search AppBundle: 0
Search AppBundle Last: 1
Search AppBundle First: 0
CMAKE_FIND_USE_CMAKE_PATH: 1
CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1
CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 1
CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1
CMAKE_FIND_USE_INSTALL_PREFIX: 1
find_library considered the following locations:
The item was found at
/Users/michaeltryby/Workspace/local/vcpkg-openmp-example/vcpkg/installed/x64-osx/debug/lib/libomp.dylib
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.27.6/share/cmake/Modules/FindOpenMP.cmake:483 (_OPENMP_GET_FLAGS)
/Users/michaeltryby/Workspace/local/vcpkg-openmp-example/vcpkg/scripts/buildsystems/vcpkg.cmake:859 (_find_package)
CMakeLists.txt:34 (find_package)
CMake Debug Log at /usr/local/Cellar/cmake/3.27.6/share/cmake/Modules/FindOpenMP.cmake:322 (find_path):
find_path called with the following settings:
VAR: OpenMP_CXX_INCLUDE_DIR
NAMES: "omp.h"
Documentation: Path to a file.
Framework
Only Search Frameworks: 0
Search Frameworks Last: 1
Search Frameworks First: 0
AppBundle
Only Search AppBundle: 0
Search AppBundle Last: 1
Search AppBundle First: 0
CMAKE_FIND_USE_CMAKE_PATH: 1
CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1
CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 1
CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1
CMAKE_FIND_USE_INSTALL_PREFIX: 1
find_path considered the following locations:
/Users/michaeltryby/Workspace/local/vcpkg-openmp-example/vcpkg/installed/x64-osx/debug/include/omp.h
...
The item was found at
/Users/michaeltryby/Workspace/local/vcpkg-openmp-example/vcpkg/installed/x64-osx/include/omp.h
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.27.6/share/cmake/Modules/FindOpenMP.cmake:483 (_OPENMP_GET_FLAGS)
/Users/michaeltryby/Workspace/local/vcpkg-openmp-example/vcpkg/scripts/buildsystems/vcpkg.cmake:859 (_find_package)
CMakeLists.txt:34 (find_package)
CMake Error at /usr/local/Cellar/cmake/3.27.6/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES)
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.27.6/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
/usr/local/Cellar/cmake/3.27.6/share/cmake/Modules/FindOpenMP.cmake:577 (find_package_handle_standard_args)
/Users/michaeltryby/Workspace/local/vcpkg-openmp-example/vcpkg/scripts/buildsystems/vcpkg.cmake:859 (_find_package)
CMakeLists.txt:34 (find_package)
CMake Debug Log at /Users/michaeltryby/Workspace/local/vcpkg-openmp-example/vcpkg/scripts/buildsystems/vcpkg.cmake:859 (_find_package):
find_package considered the following paths for FindOpenMP.cmake:
The file was found at
/usr/local/Cellar/cmake/3.27.6/share/cmake/Modules/FindOpenMP.cmake
Call Stack (most recent call first):
CMakeLists.txt:34 (find_package)
-- Configuring incomplete, errors occurred!