[CMake] how to define global compiler flags that are inserted before user-defined flags?

René J.V. Bertin rjvbertin at gmail.com
Wed Sep 3 13:37:30 EDT 2014


I was referred here from http://public.kitware.com/Bug/view.php?id=15127 ... so here goes:

KDE defines a number of compiler options that are (supposedly) required but that include optimisation options. These settings are defined in system-wide .cmake files like FindKDE4Internal.cmake and get applied *after* user-specified settings have been applied. They even seem to override tweaks made directly in CMakeCache.txt (to CMAKE_CXX_FLAGS_RELEASE or _RELWITHDEBINFO).
Even if user-specified compiler flags do make it to the list in the generated *.make files, the KDE/system-defined options are *appended* to the list, causing -O2 to override -O3 or -g -g3. 

Is it possible to specify the KDE/system options in such a way that they appear at the start of the options list in the *.make files?
With user-defined I mean specified on the commandline, through the environment, or (even) by editing CMakeCache.txt .
I raised an issue about this on bugs.kde.org, but it could be constructive to be able to propose a solution/alternative (and I guess the real experts are here, not on kde.org ;) ).

Regards,
René Bertin


More information about the CMake mailing list