MantisBT - CMake
View Issue Details
0014753CMakeCMakepublic2014-02-12 20:082016-06-10 14:31
Dmitry Marakasov 
Kitware Robot 
normaltweakalways
closedmoved 
amd64FreeBSD10.0
CMake 2.8.12.1 
 
0014753: Place CMAKE_CXX_FLAGS_DEBUG before CMAKE_CXX_FLAGS, not after (for all similar flags)
The example below goes to CMAKE_CXX_FLAGS_DEBUG, however the report covers all flags which have CMAKE_BUILD_TYPE-dependent counterparts (e.g. CMAKE_{C,CXX,LINK,...}_FLAGS_*)

Currently, CMAKE_CXX_FLAGS_DEBUG goes to compiler flags after CMAKE_CXX_FLAGS. This is inconvenient, as it does not allow user to override project-set flags with flags suitable for local environment. For example, FreeBSD ports collection has a policy of enforcing systemwide optimization (-Ox) flags on all port builds. These flags are passed via CMAKE_CC_FLAGS/CMAKE_CXX_FLAGS, but when BUILD_TYPE is used (it is) they do not override project-set flags, which is undesirable. The only ways to fix this are either to not use CMAKE_BUILD_TYPE (which is not acceptable as build-type specific flags may contain critical features, e.g. -DNDEBUG which may severely affect performance and program bahavior) or patch CMakeLists.txt to remove unwanted vendor's flags (not very nice either).

Placing CMAKE_*_FLAGS _after_ CMAKE_*_FLAGS_* will allow gracefully overriding of needed flags so that is what I propose.
No tags attached.
Issue History
2014-02-12 20:08Dmitry MarakasovNew Issue
2014-02-12 20:43Ben BoeckelNote Added: 0035096
2014-02-12 21:28Dmitry MarakasovNote Added: 0035097
2016-06-10 14:29Kitware RobotNote Added: 0042485
2016-06-10 14:29Kitware RobotStatusnew => resolved
2016-06-10 14:29Kitware RobotResolutionopen => moved
2016-06-10 14:29Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0035096)
Ben Boeckel   
2014-02-12 20:43   
This is probably a backwards compatibility issue. Adding CMAKE_${LANG}_FLAGS_${CONFIG}_AFTER might be best. They'd go after CMAKE_${LANG}_FLAGS, but before target- and source file-specific flags. Alternatively, FreeBSD's platform files could have different defaults for per-configuration flags (e.g., -Ox instead of -O3).
(0035097)
Dmitry Marakasov   
2014-02-12 21:28   
> Adding CMAKE_${LANG}_FLAGS_${CONFIG}_AFTER might be best. They'd go after CMAKE_${LANG}_FLAGS, but before target- and source file-specific flags.

Sounds fine.

> Alternatively, FreeBSD's platform files could have different defaults for per-configuration flags (e.g., -Ox instead of -O3).

Won't work since projects redefine these.
(0042485)
Kitware Robot   
2016-06-10 14:29   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.