[Cmake] Bug in 2.0.2: How to do configuration specific options inthe MS Visual Studio Projects

Brad King brad.king at kitware.com
Thu Jul 29 11:38:45 EDT 2004


Rajiv Bhagwat wrote:
> 1. During 'configure', I get the error:
> Parse error. Function missing ending ")". Instead found "("
> indicating the line containing $(IntDir).

Put the argument in double quotes:

   "${PRJ_PATH}/winbuild/$(IntDir)/libname.lib"

> 2. I had read about 'debug - optimised' modifiers. When tried, found the
> following problems with it:
> 
> 2a. How to get the lib for each of the 4 builds (Debug, Release, MinSizeRel
> & RelWithDebInfo) is not very clear.. Two options-> Four combinations seems
> ok, till you get: debug+optimised = RelWithDebInfo???
> Use of a single modifier such as either of: D,R,M,I or 0-3 would be clearer.
> 
> 2b. Testing with only 1 library, I used:
> TARGET_LINK_LIBRARIES(progname libname debug )
> Which crashed CMake with a big thud... Should I try 'progname debug
> libname'? I assumed 'debug' would apply to the previous libname, the
> document says otherwise.
> 
> 2c. How exactly should the library path be specified if using the 'debug ..'
> modifiers? i.e. Would CMake not have to figure out the directory and insert
> it in path just before '/libname.lib'?
> i.e. use of
> TARGET_LINK_LIBRARIES(progname ${PRJ_PATH}/winbuild/libname.lib)
> instead of:
> TARGET_LINK_LIBRARIES(progname ${PRJ_PATH}/winbuild/$(IntDir)/libname.lib)
> appears confusing, when we know that there is an option dependant directory
> in-between.
> 
> Have been playing with CMake for 6 months or so, but space+time
> considerations of compiling every library as a part of every project was not
> very attractive...

The debug/optimized options are intended to be used when the external 
library was not built by CMake.  If your other projects are all built by 
CMake, then there is already a whole bunch of support in CMake to import 
these libraries and automatically get the build types to mach.

What you need to do is setup each project that builds libraries to 
export this information into a FOOConfig.cmake file at the top of the 
build tree.  Once this is setup, then you can use the libraries in 
another project like this:

   FIND_PACKAGE(FOO)
   INCLUDE_DIRECTORIES(${FOO_INCLUDE_DIRS})
   LINK_DIRECTORIES(${FOO_LIBRARY_DIRS})
   ADD_EXECUTABLE(bar bar.cxx)
   TARGET_LINK_LIBRARIES(bar foo)

In this example the FOO project exports library "foo".  Then this other 
project imports FOO and links against the library.  All libraries on 
which foo depends are automatically pulled in.

This all works very nicely and we have many interdependent projects that 
work this way.  There are detailed instructions on how to do this in the 
book "Mastering CMake" in chapter 6, section 7.  See here for a link:

http://www.cmake.org/HTML/Documentation.html

-Brad


More information about the Cmake mailing list