[CMake] Supported configurations with Visual Studio builds

Joshua Jensen jjensen at workspacewhiz.com
Mon Oct 8 16:02:22 EDT 2007


Sylvain Benner wrote:
>> What about the debug/optimized flags for TARGET_LINK_LIBARIES()?  Do
>> these work right now by taking advantage of the fact that Debug,
>> Release, MinSizeRel, and RelWithDebInfo are hardcoded?  
> We had to "upgrade" the cmTarget sources to add the new configuration 
> type and then use the LINK_LIBRARIES command correctly. Actually this 
> is the only thing that prevent us from defining new configuration 
> types without hardcoding anything, configuration types merely never 
> change so this is not an annoying thing for us, but this is a big 
> blocking issue if you want to add this feature in a release.
>
My version of CMake with the following changes can be found at:

svn co svn://svn.luaplus.org/CMake/patches/All CMake

Most notably is the support in TARGET_LINK_LIBRARIES for multiple configs.

Windows-cl.cmake:

* Reservation of a 10 megabyte stack in Windows-cl.cmake is overkill.  
The default is 1 megabyte.  Why is this here?  I removed it.
* Visual Studio 2005 doesn't understand /MACHINE:I386.  I changed it to 
/MACHINE:X86.
* All /debug linker entries were changed to /DEBUG.  CMake deals with 
these in a case sensitive fashion.  The Visual C++ linker does not, but 
all documentation has them all caps.

FindwxWidgets.cmake:

* Ability to find the wxAUI library.
* Can find wxWidgets 2.9 libraries.

Various .cxx files:

* I commented out the explicit checks for config names of Debug, 
Release, MinSizeRel, and RelWithDebInfo.  In my projects, I use configs 
like Debug, Release, Profile, Armor, Release LTCG, and so on.  
Commenting out the explicit checks allows generation of those configs 
into the resulting .vcproj file.
* Added support for .vcproj entries to help unclutter the command line: 
OptimizeReferences, EnableCOMDATFolding, GenerateDebugInformation, and 
TargetMachine.
* Handle the source file property EXCLUDED_FROM_BUILD.  This makes 
Visual Studio properly exclude the file from a .vcproj.
* Put CMake targets in a CMake_Targets solution folder in Visual Studio.
* Added support for TARGET_LINK_LIBRARIES(Target config::ConfigName 
libraries).  This is probably the wrong way to go about doing it, but it 
works, and I made sure it was backward compatible with the 
TARGET_LINK_LIBRARIES options 'debug' and 'optimized'.  Different 
configurations require different external libraries, and specifying 
those link libraries per config helps immensely.  Sadly, other important 
commands like INCLUDE_DIRECTORIES and LINK_DIRECTORIES are not 
config-sensitive for .vcproj files.  I need to look into that more, 
unless someone has a better idea.  This was, in part, talked about in 
this thread: 
http://public.kitware.com/pipermail/cmake/2004-August/005464.html

For instance:

TARGET_LINK_LIBRARIES(MyApp config::Debug wxmsw28d_core wxbase28d 
wxmsw28d_adv wxmsw28d_html wxbase28d_xml wxexpatd wxmsw28d_xrc 
wxmsw28d_gl wxjpegd wxpngd wxzlibd wxregexd wxdockitd wxmsw28d_propgrid)
TARGET_LINK_LIBRARIES(MyApp config::Release wxmsw28_core wxbase28 
wxmsw28_adv wxmsw28_html wxbase28_xml wxexpat wxmsw28_xrc wxmsw28_gl 
wxjpeg wxpng wxzlib wxregex wxdockit wxmsw28_propgrid)
TARGET_LINK_LIBRARIES(MyApp config::ReleaseFinal wxmsw28_core wxbase28 
wxmsw28_adv wxmsw28_html wxbase28_xml wxexpat wxmsw28_xrc wxmsw28_gl 
wxjpeg wxpng wxzlib wxregex wxdockit wxmsw28_propgrid)

-Josh


More information about the CMake mailing list