[CMake] custom configuration types and linking with 3rd-party libs

cyril_wobow cyril at wobow.com
Sat Aug 23 12:47:34 EDT 2008


Hi,

I set my project's CMAKE_CONFIGURATION_TYPES variable with some custom 
configurations (e.g. GuiDebug, GuiRelease, ConsoleDebug, ConsoleRelease).
Each of them have their own compilation flags, which is great, 
especially for visual studio users that don't want to bother with a 
config.h.in file but prefer a nice, expressive configuration list. This 
works just fine.

Unfortunately, there is a showstopper : when it comes to linking, tell 
me if I am wrong, there is no way to express which configuration type 
should link against which library. In particular, all my configuration 
types end up linking against the release version of my 3rd party libraries.

1st possible solution :
Is there a way to specify libraries to link with, using a 
XX_<CONFIG>-style variable ?

2nd possible solution :
Is there a way to specify, for each configuration type I declare in 
CMAKE_CONFIGURATION_TYPES, if it is a "debug" or "optimized" 
configuration ? A quick look at cmake sources makes me think that the 
relation between a configuration type and its debug/optimized flavour is 
hardcoded so that only config types named Debug (or deBUg or DEbuG) are 
considered to be debug-flavoured configs. Which is embarrassing because 
GuiDebug and ConsoleDebug would love to link against Qt debug libraries 
for instance.

I would prefer to achieve the 2nd solution because it would be 
compatible with existing cmake modules.

Kind regards
Cyril


More information about the CMake mailing list