Original CMakeOutput.log (there wasn't any CMakeError.log
).
And trace.log from --trace-expand
run.
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):
find_package(OpenMP)
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)
FindOpenMP still doesn't work for me on macOS Catalina (10.15.7). Using CMake 3.20.1.
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)
So I tried a bunch of stuff from here.
if(APPLE)
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
set(OpenMP_C "${CMAKE_C_COMPILER}")
set(OpenMP_C_FLAGS "-fopenmp=libomp -Wno-unused-command-line-argument")
set(OpenMP_C_LIB_NAMES "libomp" "libgomp" "libiomp5")
set(OpenMP_libomp_LIBRARY ${OpenMP_C_LIB_NAMES})
set(OpenMP_libgomp_LIBRARY ${OpenMP_C_LIB_NAMES})
set(OpenMP_libiomp5_LIBRARY ${OpenMP_C_LIB_NAMES})
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(OpenMP_CXX "${CMAKE_CXX_COMPILER}")
set(OpenMP_CXX_FLAGS "-fopenmp=libomp -Wno-unused-command-line-argument")
set(OpenMP_CXX_LIB_NAMES "libomp" "libgomp" "libiomp5")
set(OpenMP_libomp_LIBRARY ${OpenMP_CXX_LIB_NAMES})
set(OpenMP_libgomp_LIBRARY ${OpenMP_CXX_LIB_NAMES})
set(OpenMP_libiomp5_LIBRARY ${OpenMP_CXX_LIB_NAMES})
endif()
endif()
find_package(OpenMP)
This the makes the compile work but the lib path somehow doesn't make it through as I get:
ld: library not found for -lomp
So then I tried this (next answer from above's StackOverflow thread):
if(APPLE)
if(CMAKE_C_COMPILER_ID MATCHES "Clang\$")
set(OpenMP_C_FLAGS "-Xpreprocessor -fopenmp")
set(OpenMP_C_LIB_NAMES "omp")
set(OpenMP_omp_LIBRARY omp)
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang\$")
set(OpenMP_CXX_FLAGS "-Xpreprocessor -fopenmp")
set(OpenMP_CXX_LIB_NAMES "omp")
set(OpenMP_omp_LIBRARY omp)
endif()
endif
find_package(OpenMP)
This also doesn't work.
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:
[...]