linker cannot find openmp library on msys system

I am using FIND_PACKAGE(OpenMP) on mysy2 and then linking the necessary libraries using


This works find on most systems, but on msys2 I get the following error during linking:

cannot find -lC:/msys64/mingw64/lib/libcomp.dll.a

If I use verbose makefiles to get the linker command. Then execute the linker command with all occurrences of ‘-lC:/’ changed to 'C:/`, the linker command works fine. Is this a problem with the linker command generated by cmake ?

This was a problem with the version of cmake;see