[CMake] Different configurations for Debug and Release

Michael Wild themiwi at gmail.com
Tue Jun 8 09:05:43 EDT 2010


On 8. Jun, 2010, at 14:45 , Torri, Stephen CIV NSWCDD, W15 wrote:

>> From: cmake-bounces at cmake.org on behalf of Tyler Roscoe
>> Sent: Mon 6/7/2010 4:25 PM
>> To: Felipe Sodré Silva
>> Cc: cmake at cmake.org
>> Subject: Re: [CMake] Different configurations for Debug and Release
>> 
>>> On Mon, Jun 07, 2010 at 03:04:02PM -0300, Felipe Sodré Silva wrote:
>>> The CXX_FLAGS part seems to work (I needed the LINK_FLAGS_RELEASE), but I
>>> also need to include a library (through target_link_libraries) if and only
>>> if I am building a release version. Is that possible?
>> 
>> Look at the debug and optimized flags for target_link_libraries().
> 
> In my project the external libraries I use have the debug library files are in a different directory from the release versions. I don't think I can use target_link_libraries to include a path as well as the name. In documentation I would use link_directories but there is no way in the syntax to distinguish a debug directory from a release directory. I am trying to generate a Visual Studio project that can build a debug release if I select "Debug" in the configuration manager drop down menu or "Release". Is there a way for me to tell CMake that a certain set of directories the linker should use to search for files for the debug build versus another?
> 
> Stephen 
> 

Either use

target_link_libraries(<target> debug <debug_lib> optimized <opt_lib> general <gen_lib>)

or, for more control, create an imported library (add_library(<lib_target> IMPORTED)) and set the IMPORTED_LOCATION_<config> target properties to specify the location on the disk for each of the configurations you want to handle.

HTH

Michael



More information about the CMake mailing list