blt icon indicating copy to clipboard operation
blt copied to clipboard

OpenMP flags set by user get overridden by blt/cmake/thirdparty/SetupOpenMP.cmake

Open mcordery opened this issue 5 years ago • 0 comments

In setting flags during configure via

cmake ..
.. .. -DOpenMP_CXX_FLAGS="-flag1 -flag2"
..

these get overridden in blt/cmake/thirdparty/SetupOpenMP.cmake after the find_package(OpenMP REQUIRED) call (at least with the compiler I'm using). This is particularly an issue, though, with compilers where an additional flag is required to offload OpenMP target regions. In the above example, the find_package() call will find an OpenMP flag (that may be deprecated) and the overwrite the values I specified in OpenMP_CXX_FLAGS. For example, if find_package finds a flag called flag0, it will set OpenMP_CXX_FLAGS=-flag0. If I try to get around this by setting

cmake ..
.. .. -DOpenMP_CXX_FLAGS="-flag1 -flag2"
-DBLT_OPENMP_COMPILE_FLAGS="-flag1 -flag2"
..

Then what happens is that compile_flags does get set but it gets set with the string including the double quotes so the compile ends up looking like

cc ..... "-flag1 -flag2" ....

instead of

cc .... -flag1 -flag2 .....

There's probably a way to strip these quotes off with cmake but I'm not enough of a cmake expert to know how to do that and I think that mode of behavior should be to honor the flags set by the user.

mcordery avatar Sep 10 '20 16:09 mcordery