FindOpenMP: OpenMP_${LANG}_FLAGS set with FORCE
The behaviour of the OpenMP_${LANG}_FLAGS
variable set/used by the FindOpenMP
module is inconsistent between C/C++ and Fortran:
- For C/C++, both
OpenMP_${LANG}_FLAGS
andOpenMP_${LANG}_LIB_NAMES
are CACHE variables that are set withFORCE
(see https://gitlab.kitware.com/cmake/cmake/-/blob/0f65ab5bcb66f94e5ab20b095d5a3296a36ccd02/Modules/FindOpenMP.cmake#L475-487). - For Fortran, they are set without
FORCE
(https://gitlab.kitware.com/cmake/cmake/-/blob/0f65ab5bcb66f94e5ab20b095d5a3296a36ccd02/Modules/FindOpenMP.cmake#L499-502).
The latter is more desirable (for us, anyway) as it allows to selectively override the OpenMP-flags to supply bespoke additional options, e.g. related to offload targets, without disabling the auto-discovery of other parts of the OpenMP runtime.
Is there a specific reason for the use of FORCE
here or any other recommended best-practices with respect to supplying additional OpenMP compiler flags?
Edited by Brad King