FindOpenMP is unable to recovery when the library is not found
System: Debian GNU/Linux 10
, Compiler: clang-8
, CMake: 3.13.4
If I try to compile my project which contains these instructions:
find_package(OpenMP REQUIRED)
target_link_libraries(betaboltz PRIVATE OpenMP::OpenMP_CXX)
without the OpenMP library installed, I get this error:
CMake Error at /usr/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES)
Call Stack (most recent call first):
/usr/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-3.13/Modules/FindOpenMP.cmake:473 (find_package_handle_standard_args)
CMakeLists.txt:43 (find_package)
Checking the defined variables, I can find:
OpenMP_CXX_FLAGS *NOTFOUND
OpenMP_CXX_LIB_NAMES *NOTFOUND
If then I install OpenMP:
sudo apt install libomp-8-dev
I still have the same error because the variable are persistent. To be able to continue, I had to manually delete both variables.
I think it should not be the default behaviour because I may confuse any inexperienced user like myself.
The proposed solution is to make these variables transient and the error message a bit more clear.
Edited by Michele Renda