MantisBT - CMake
View Issue Details
0006493CMakeCMakepublic2008-03-02 22:502013-11-04 09:33
muhkuh 
Stephen Kelly 
normalfeaturealways
closedfixed 
 
 
0006493: configuration dependent COMPILE_FLAGS for SET_TARGET_PROPERTIES
There already are configuration dependent LINK_FLAGS like LINK_FLAGS_DEBUG, LINK_FLAGS_RELEASE. This could be usefule for COMPILE_FLAGS too.
My use case for this is generating mutiple versions of the same library using different C runtimes.
No tags attached.
has duplicate 0009940closed Brad King support for COMPILE_FLAG_<CONFIG> 
has duplicate 0008362closed Brad King cmake fails executing the command in link.txt with continuation characters in CMAKE_C_FLAGS 
related to 0006269closed Stephen Kelly Some CMake commands should support Debug/Release configurations 
related to 0014182closed Kitware Robot set_property file.c PROPERTY COMPILE_FLAGS should allow a list of flags 
patch compile_flags_config.patch (841) 2008-04-21 04:47
https://public.kitware.com/Bug/file/1422/*
patch compile_flags_config_makefile.patch (1,652) 2008-05-22 07:08
https://public.kitware.com/Bug/file/1488/*
diff compile_flags.diff (13,283) 2008-07-14 10:47
https://public.kitware.com/Bug/file/1596/*
patch 0001-COMPILE_FLAGS_-CONFIG.patch (13,903) 2012-10-25 18:30
https://public.kitware.com/Bug/file/4542/*
Issue History
2008-03-02 22:50muhkuhNew Issue
2008-03-18 21:45muhkuhNote Added: 0010850
2008-04-21 04:46Egon KocjanNote Added: 0011446
2008-04-21 04:47Egon KocjanFile Added: compile_flags_config.patch
2008-05-22 07:08Egon KocjanFile Added: compile_flags_config_makefile.patch
2008-05-22 07:09Egon KocjanNote Added: 0012066
2008-07-14 10:46Slavoj PísekNote Added: 0012695
2008-07-14 10:47Slavoj PísekFile Added: compile_flags.diff
2008-08-19 14:21Bill HoffmanStatusnew => assigned
2008-08-19 14:21Bill HoffmanAssigned To => Brad King
2008-08-19 14:35Brad KingRelationship addedrelated to 0006269
2008-10-09 15:37Brad KingNote Added: 0013821
2009-07-07 03:44Lluís BatlleNote Added: 0016818
2009-09-19 23:36TarasNote Added: 0017655
2009-10-20 17:16Steve WilsonNote Added: 0018131
2010-07-29 13:47Jeremy CoulonNote Added: 0021558
2010-07-29 13:50Jeremy CoulonNote Edited: 0021558
2010-07-29 14:20Brad KingNote Added: 0021559
2010-08-01 06:52Jeremy CoulonNote Added: 0021589
2010-08-01 15:22Brad KingNote Added: 0021590
2010-12-14 17:00Brad KingRelationship addedhas duplicate 0009940
2011-01-18 11:51Brad KingRelationship addedhas duplicate 0008362
2011-03-02 18:09AndrewFNote Added: 0025624
2011-07-07 10:14jens.koehler@mobotix.comNote Added: 0027016
2011-07-29 18:04Brad KingNote Added: 0027125
2011-07-29 18:04Brad KingAssigned ToBrad King =>
2011-07-29 18:04Brad KingStatusassigned => backlog
2011-08-01 11:19David ColeNote Added: 0027142
2012-08-27 07:30Stephen KellyAssigned To => Stephen Kelly
2012-08-27 07:30Stephen KellyStatusbacklog => assigned
2012-10-25 18:30viktor11111File Added: 0001-COMPILE_FLAGS_-CONFIG.patch
2012-10-25 18:32viktor11111Note Added: 0031338
2012-10-25 18:34viktor11111Note Edited: 0031338bug_revision_view_page.php?bugnote_id=31338#r879
2012-10-25 18:35viktor11111Note Edited: 0031338bug_revision_view_page.php?bugnote_id=31338#r880
2013-02-04 10:07ParisNote Added: 0032191
2013-02-07 09:05Sylwester ArabasNote Added: 0032208
2013-02-13 14:35David ManuraNote Added: 0032269
2013-05-31 08:06Brad KingRelationship addedrelated to 0014182
2013-06-03 12:52Stephen KellyNote Added: 0033214
2013-06-03 12:52Stephen KellyStatusassigned => resolved
2013-06-03 12:52Stephen KellyResolutionopen => fixed
2013-11-04 09:33Robert MaynardNote Added: 0034355
2013-11-04 09:33Robert MaynardStatusresolved => closed

Notes
(0010850)
muhkuh   
2008-03-18 21:45   
Additionally it would be a good idea to make a difference between C and CXX flags. These target properties would be nice:

CXX_FLAGS_DEBUG
CXX_FLAGS_RELEASE
CXX_FLAGS_MINSIZEREL
CXX_FLAGS_RELWITHDEBINFO

C_FLAGS_DEBUG
C_FLAGS_RELEASE
C_FLAGS_MINSIZEREL
C_FLAGS_RELWITHDEBINFO
(0011446)
Egon Kocjan   
2008-04-21 04:46   
Separate compiler flags are an absolute necessity for me, so I created a simple hack to add COMPILE_FLAGS_<CONFIG> for Visual Studio generator (patch is attached). I am quite new to cmake, so I don't know how to make it for xcode and makefiles yet, maybe my coworkers will figure it out later when they port the new cmake based build system. It would be nice to have a comment on this feature from cmake developers, before we make too many CMakeLists.txt depend on our hacks ;)
(0012066)
Egon Kocjan   
2008-05-22 07:09   
I've attached a patch to add COMPILE_FLAGS_<CONFIG> for Makefile generator.
(0012695)
Slavoj Písek   
2008-07-14 10:46   
Honestly muhkuh is not the only one who would appreciate COMPILE_FLAGS_<CONFIG>. I need it as well.
Unfortunatelly the patches ekojcan has uploaded are not complete. It does not work for VS6 and newly introduced COMPILE_FLAGS_<CONFIG> works for targets only. To be consistent it is necessary to have COMPILE_FLAGS_<CONFIG> even for source file properties.

I have made and uploaded a new patch. And I hope cmake developers will review it and they will find it useful and integrate it to cmake sources. It would be nice to have it in the next CMake release.
(0013821)
Brad King   
2008-10-09 15:37   
FYI, I've been working on a solution for this on-and-off for a couple months. Instead of extending the COMPILE_FLAGS property, which is space-separated for historical reasons, I am creating a new COMPILE_OPTIONS property which is semicolon-separated like everything else in CMake. Unfortunately doing this right (and providing per-config, per-directory, per-target versions) is a bit of a can of worms. It requires some refactoring and cleanup of the VS and Xcode generators. I'm working on it, but it's not done yet.
(0016818)
Lluís Batlle   
2009-07-07 03:44   
Any update on this? We would also like the brad.king work upstream.
Thank you.
(0017655)
Taras   
2009-09-19 23:36   
Yeah and we
(0018131)
Steve Wilson   
2009-10-20 17:16   
I'ld like to add myself to the list of those people that are keen to see this change implemented.
(0021558)
Jeremy Coulon   
2010-07-29 13:47   
(edited on: 2010-07-29 13:50)
I am very interested by this feature !
Is it going to be implemented anytime soon ?

I don't really want to recompile my own patched version of CMake.
So, I tried this workaround but it doesn't work :

set (CMAKE_CXX_FLAGS_DEBUG_BACKUP ${CMAKE_CXX_FLAGS_DEBUG})
set (CMAKE_CXX_FLAGS_DEBUG "/MTd")
add_library (...)
set (CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG_BACKUP})

(0021559)
Brad King   
2010-07-29 14:20   
I just pushed the work I mentioned in comment 13821 out to a topic branch:

  http://gitorious.org/~bradking/cmake/bradkings-cmake/commits/compile-options [^]

If anyone would like to rebase, modernize, and finish the work on top of the latest 'master' I can guide you.
(0021589)
Jeremy Coulon   
2010-08-01 06:52   
I tried your branch and it works fine with VS 2003.
(0021590)
Brad King   
2010-08-01 15:22   
Great, thanks for trying it. Note that the head of the branch is actually from 2 years ago.

There is a bunch of work needed before we can include these changes. We need at least the following:

 - Rebase on current master (will need conflict resolution)
 - Implement support for all platforms (partially complete)
 - Add tests
 - Documentation of the properties
(0025624)
AndrewF   
2011-03-02 18:09   
I'll just throw in a bump for this issue. We just ran into this limitation when trying to provide the option for setting the /MDd /MD /MTd or /MT flags, for a mixture of static and dynamic library builds, on a cmake generated project in Visual Studio.

It looks like configuration dependent compile flags are by far the best way to make this happen. COMPILE_DEFINITIONS_ don't cut it since it implies an automatic /D infront of the parameters passed in.
(0027016)
jens.koehler@mobotix.com   
2011-07-07 10:14   
I'ld like to add myself to the list of those people that are keen to see this change implemented.
(0027125)
Brad King   
2011-07-29 18:04   
Moving to backlog as I have no time to continue work on this now.

Comment 0006493:0021590 describes additional work required. If anyone wants to step forward please post.
(0027142)
David Cole   
2011-08-01 11:19   
Brad just put this one in the backlog... I'm not going to put it on the roadmap for 2.8.6 unless somebody else steps forward with more work on this, as noted by Brad in his previous comments here.
(0031338)
viktor11111   
2012-10-25 18:32   
(edited on: 2012-10-25 18:35)
this feature is very necessary, please take this time.


updated the old patch for the latest revision

used "0001-COMPILE_FLAGS_-CONFIG.patch"

(0032191)
Paris   
2013-02-04 10:07   
Any update on this one?
Strange that such a basic feature is not worked out since 5 years now...
(0032208)
Sylwester Arabas   
2013-02-07 09:05   
I concur - this would be very useful!
(0032269)
David Manura   
2013-02-13 14:35   
I want this too. It's also discussed on
http://stackoverflow.com/questions/10199904/how-can-i-set-specific-compiler-flags-for-for-a-specific-target-in-a-specific-bu [^]
(0033214)
Stephen Kelly   
2013-06-03 12:52   
This is now possible by populating the COMPILE_OPTIONS target property with generator expressions. A target_compile_options command has been added as an abstraction to populating the property.
(0034355)
Robert Maynard   
2013-11-04 09:33   
Closing resolved issues that have not been updated in more than 4 months.