MacOS, Clang, OpenMP - Fails to find OpenMP because of -Werror
When having
find_package( OpenMP )
in newest version of CMake, building with
$ cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DUSE_WERROR=ON
will fail to find OpenMP silently. This is caused by the try_compile
in https://gitlab.kitware.com/cmake/cmake/blob/v3.9.3/Modules/FindOpenMP.cmake#L170 issues the compile with -Werror
, but also with an unused linker argument. Thus Clang fails with -Wunused-command-line-argument
and cannot find OpenMP as a result.
Adding -Wno-unused-command-line-argument
to the OPENMP_FLAG
variable solves this (I am however unsure if this is the correct way of doing it)
Edited by Brad King