It looks like the tests in FindOpenMP.cmake are not running and finding OpenMP on macOS because they are missing the /usr/local/include directory.
The proper fix would be to add a search for omp.h and then use that include directory in the targets, and that would also fix #18098 (closed) and could fix #17474.
Edited
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items 0
Show closed items
No child items are currently assigned. Use child items to break down this issue into smaller parts.
Linked items 0
Link issues together to show that they're related.
Learn more.
FindOpenMP still doesn't work for me on macOS Catalina (10.15.7). Using CMake 3.20.1.
It does not work in Homebrew
I have libomp installed via Homebrew.
brew install libomp
Which installs:
/usr/local/opt/llvm/lib/libomp.dylib
Supposedly this should be enough to build OpenMP code even with Apple's Clang.
But that doesn't work.
I get:
clang: error: unsupported argument 'libomp' to option 'fopenmp='
So I also installed Homebrew's Clang which has OpenMP support and set
CMAKE_C_COMPILER and CMAKE_CXX_COMPILER to the location of Homebrew's clang/clang++.
After this I get:
-- 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)
Undefined symbols for architecture x86_64: "___kmpc_for_static_fini", referenced from: _.omp_outlined._debug__ in ompEvaluator.cpp.o _.omp_outlined._debug__.1 in ompEvaluator.cpp.o _.omp_outlined._debug__.3 in ompEvaluator.cpp.o _.omp_outlined._debug__ in ompKernel.cpp.o _.omp_outlined._debug__.3 in ompKernel.cpp.o _.omp_outlined._debug__.5 in ompKernel.cpp.o "___kmpc_for_static_init_4", referenced from: _.omp_outlined._debug__ in ompEvaluator.cpp.o _.omp_outlined._debug__.1 in ompEvaluator.cpp.o _.omp_outlined._debug__.3 in ompEvaluator.cpp.o _.omp_outlined._debug__ in ompKernel.cpp.o _.omp_outlined._debug__.3 in ompKernel.cpp.o _.omp_outlined._debug__.5 in ompKernel.cpp.o "___kmpc_fork_call", referenced from: [...]
The C compiler identification is AppleClang 12.0.0.12000032...Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped...The CXX compiler identification is AppleClang 12.0.0.12000032...Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped...Found OpenMP_C: -Xclang -fopenmp (found version "4.5") Found OpenMP_CXX: -Xclang -fopenmp (found version "4.5") Found OpenMP: TRUE (found version "4.5")
Your problem is with Homebrew's compiler and OpenMP package. Please open a new issue for that.
Your problem is with Homebrew's compiler and OpenMP package. Please open a new issue for that.
@brad.king
Nope. As I wrote, I tried with Apple Clang first.
I also uninstalled the Homebrew libomp package to be sure and tried again:
❯ cmake -DNO_EXAMPLES=1 -DNO_TUTORIALS=1 -DNO_REGRESSION=1 -DNO_PTEX=1 -DNO_DOC=1 -DNO_OPENCL=1 -DNO_CLEW=1 -DNO_TBB=1 -DNO_METAL=1 -DNO_CUDA=1 .. 2.204.229.42 100% -- The C compiler identification is AppleClang 12.0.0.12000032-- The CXX compiler identification is AppleClang 12.0.0.12000032-- Detecting C compiler ABI info-- Detecting C compiler ABI info - done-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped-- Detecting C compile features-- Detecting C compile features - done-- 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/c++ - skipped-- Detecting CXX compile features-- Detecting CXX compile features - done-- Compiling OpenSubdiv version v3_4_4-- Using cmake version 3.20.1-- 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)
That looks like some complex project. Please try a simple CMakeLists.txt file. For example:
$cat ../CMakeLists.txtcmake_minimum_required(VERSION 3.19)project(Issue18470)find_package(OpenMP COMPONENTS C CXX)$cmake --versioncmake version 3.20.1...$cmake ..-- The C compiler identification is AppleClang 12.0.0.12000032-- The CXX compiler identification is AppleClang 12.0.0.12000032...-- Found OpenMP_C: -Xclang -fopenmp (found version "4.5")-- Found OpenMP_CXX: -Xclang -fopenmp (found version "4.5")-- Found OpenMP: TRUE (found version "4.5") found components: C CXX...
If that works, please try to narrow down the failing project to a minimal example.
BTW, please use the "Reply..." box in this discussion thread instead of posting a separate comment to reply.
Hey, sorry about the reply thingy. Missed that.
So I tried your minimal example and I get the same.
-- The C compiler identification is AppleClang 12.0.0.12000032-- The CXX compiler identification is AppleClang 12.0.0.12000032-- Detecting C compiler ABI info-- Detecting C compiler ABI info - done-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped-- Detecting C compile features-- Detecting C compile features - done-- 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/c++ - skipped-- Detecting CXX compile features-- Detecting CXX compile features - done-- 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)-- Configuring done-- Generating done-- Build files have been written to: /Users/moritz/code/test_cmake
P.S.: the complex project also just uses a one liner (and nothing else related to OpenMP set before/after):
Ah. I think Apple may not be providing OpenMP libraries with their Clang. The nightly test I linked above is enabled only on a specific machine that has Homebrew's libomp installed. I have it on my local machine too. I end up with: