OpenMP flags set by user get overridden by blt/cmake/thirdparty/SetupOpenMP.cmake
- Dominant language
- C++
- Stars
- 296
- Forks
- 66
- Avg merge
- 1h 3m
- Merged PRs (30d)
- 1
Description
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.
Contributor guide
Research direction
Inspect blt/cmake/thirdparty/SetupOpenMP.cmake around the find_package(OpenMP REQUIRED) call, then reproduce the configure command using OpenMP_CXX_FLAGS and BLT_OPENMP_COMPILE_FLAGS. Done means user-provided flags are honored and passed as separate compiler flags rather than being overwritten or retaining surrounding quotes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100