[CMake] debug & optimized

Martin Groher groher at in.tum.de
Thu Mar 17 02:21:26 EST 2005


Ok, I've found a solution (without the book actually):
Just set a CMake variable called 
CMAKE_DEBUG_POSTFIX
to "D", that does the whole thing. Then one can copy a debug lib with a
suffix D and the release lib to one directory.

Where's the point of this mailing list when all you get is a reference to
the book?
Thanks though, Brad.

CU
Martin

---------------------------------------------------------------
Martin Groher
Chair for Computer Aided Medical Procedures (CAMP)
Lehrstuhl für Informatikanwendungen in der Medizin
Institut für Informatik I16
TU München
fon: +49 89 289-17071
mail: groher at in.tum.de

> -----Original Message-----
> From: Brad King [mailto:brad.king at kitware.com]
> Sent: Friday, March 11, 2005 4:27 PM
> To: Martin Groher
> Cc: cmake at cmake.org
> Subject: Re: [CMake] debug & optimized
> 
> Martin Groher wrote:
> > I’ve created a library with CMake called 'viewers'. Now, I want to link
> > against this lib in another CMake project, but, on WIN32, I want to use
> the
> > debug lib in DEBUG mode and the optimized lib in RELEASE mode.
> >
> > Lib viewers: Since I don't know the path in advance where to find the
> libs
> > (and I don't want to add the path to the PATH-variable), I would like to
> > copy the created libs to a dedicated directory (viewers/lib). Now, in
> WIN32,
> > I would like to have two libs there, viewers.lib and viewersD.lib. Then
> I
> > could just used the optimized/debug keywords in the other project to
> link
> > against these libs.
> >
> > I tried to create a post-build command to copy the created viewer libs
> to
> > the viewers/lib directory, but here, I cannot tell which lib I'm
> copying,
> > debug or optimized. Since the debug/release libs have the same name, I
> don't
> > know how to do that since the keywords debug/optimized just hold for the
> > LINK_LIBRARIES and TARGET_LINK_LIBRARIES commands.
> > Is there some way to create different custom commands for
> debug/optimized
> > mode? Or any other way to somehow tell CMake how to distinguish created
> libs
> > within the same project?
> 
> You can create your own executable to do the copy operation.  Then add
> the custom command using ${CMAKE_CFG_INTDIR} as part of the source
> location.  At build time it will be expanded to ".\Debug" or ".\Release"
> depending on the build configuration.  Then your executable can check
> the directory from which it is copying the library to decide whether it
> is the debug or optimized version.
> 
> Alternatively you can follow the instructions from section 6.7 of the
> "Mastering CMake" book available here:
> 
> http://www.cmake.org/HTML/Documentation.html
> 
> This will let you setup a package configuration file for the "viewers"
> library to make it easy to link it into outside projects.
> 
> -Brad




More information about the CMake mailing list