I'm porting an OpenMP-based program to the OneAPI. To make an incremental transition I try to compile the existing program with dpcpp. The minimal CMakeLists.txt reproducing the problem in the DevCloud is attached. With the default compiler it works fine. However, if invoked with -DCMAKE_CXX_COMPILER=`which dpcpp`, it fails at the cmake configuration step with an error: > CMake Error at /usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:137 (message): > Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES)
- General Support
Can you please try compiling your code after setting OpenMP_CXX_FLAGS to -qopenmp
Please let us know if you are facing any issues.
Now only OpenMP_CXX_LIB_NAMES is missing:
CMake Error at /usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find OpenMP_CXX (missing: OpenMP_CXX_LIB_NAMES)
Please try setting the OpenMP lib path in your CMake file.
For your reference:
set(OpenMP_CXX_LIB_NAMES "libiomp5" "libomp" "libgomp")
Please let us know if this resolves your issue.
It does not. Now it fails with:
> Could NOT find OpenMP_CXX (missing: OpenMP_libiomp5_LIBRARY OpenMP_libomp_LIBRARY OpenMP_libgomp_LIBRARY)
Also manually modifying the source of each project using OpenMP does not seem scalable.
cmake merge request 3916 might be related to this issue, I'll try the latest version and get back.
I found a combination that works:
set(OpenMP_CXX_LIB_NAMES "libiomp5" "libomp" "libgomp") # in CMakeLists.txt
Invoke the latest cmake with
-DOpenMP_CXX_FLAGS="-qopenmp" -DCMAKE_LIBRARY_PATH="$(llvm-config --libdir)" -DCMAKE_CXX_COMPILER=`which dpcpp`
Passing -DOpenMP_CXX_LIB_NAMES="libiomp5;libomp;libgomp" does not work.
Need to study the matter a bit more, so far this workaround can be used.
We tried compiling our sample application with dpcpp using -qopenmp flag alone and we don't see any errors during compilation.
We couldn't reproduce your error as we don't have access to your source code. So, kindly if you can share your source code along with the CMake file we will try to reproduce the same error that you are facing. Please share the steps to reproduce document also.
The error emerges before the compilation, at the cmake step. The minimal CMakeLists.txt is attached to the original post. The contents of the script submitted to theDevCloud queue is straightforward:
cd <a working directory, choose yours>
cmake -DCMAKE_CXX_COMPILER=dpcpp -DOpenMP_CXX_FLAGS="-qopenmp" <path to the directory containing CMakeLists.txt, choose yours>
Substitute the paths in the angle brackets accordingly.
UPD: I'll prepare a single-script reproduction when I get to the laptop.
Thank you for providing all the required information. we are able to reproduce the same error which you are facing, we found out that CMake is working fine with icpc/icc/icx/icpx compilers but not with dpcpp.
We will forward this issue to the concerned team to further investigate on this.
We are glad to see that your issue is resolved with workarounds, Please let us know whether we can close this thread.