<div class="gmail_quote">On Tue, Jun 8, 2010 at 10:00 AM, Torri, Stephen CIV NSWCDD, W15 <span dir="ltr"><<a href="mailto:stephen.torri@navy.mil">stephen.torri@navy.mil</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
> From: Michael Wild [mailto:<a href="mailto:themiwi@gmail.com">themiwi@gmail.com</a>]<br>
> Sent: Tue 6/8/2010 9:05 AM<br>
> To: Torri, Stephen CIV NSWCDD, W15<br>
<div class="im">> Cc: <a href="mailto:cmake@cmake.org">cmake@cmake.org</a><br>
> Subject: Re: [CMake] Different configurations for Debug and Release<br>
><br>
><br>
</div><div class="im">> > 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?<br>
> ><br>
> > Stephen<br>
> ><br>
><br>
> Either use<br>
><br>
> target_link_libraries(<target> debug <debug_lib> optimized <opt_lib> general <gen_lib>)<br>
><br>
> 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.<br>
<br>
</div>I did not think that I could use a full path to a library in the TARGET_LINK_LIBRARIES. Is that right?</blockquote><div><br></div><div>No, that is not right. On the contrary: we recommend that you use full paths to libraries in target_link_libraries calls.</div>
<div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">I don't think what you suggest will work:<br>
<br>
TARGET_LINK_LIBRARIES ( <target> <child libs> ${Boost_LIBRARIES}<br>
${MYSQLCPPCONNECTOR_LIB_DIR}/debug/mysqlcppconn-static.lib )<br></blockquote><div><br></div><div>This should work. Do you have a problem with it if you try it?</div><div><br></div><div>You can add debug and optimized versions like this (if those libraries exist):</div>
<div><br></div><div> TARGET_LINK_LIBRARIES ( <target> <child libs> ${Boost_LIBRARIES}<br> debug ${MYSQLCPPCONNECTOR_LIB_DIR}/debug/mysqlcppconn-static.lib<br></div><div><div> optimized ${MYSQLCPPCONNECTOR_LIB_DIR}/release/mysqlcppconn-static.lib )<br>
</div><div><br></div><div>Then, in multi-configuration generators (VS and Xcode), CMake links debug to debug and release to release... Or in a makefile based build, the value of CMAKE_BUILD_TYPE is used to determine which libraries to link to.</div>
</div><div><br></div><div><br></div><div>HTH,</div><div>David</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
So I was looking at add_library. I am not sure I get the IMPORTED_LOCATION_<config>. First off what can I use for <config>? I tried IMPORTED_LOCATION_DEBUG but that gave me an error from cmake-gui saying its was an unknown cmake command. The documentation does not clearly define what <config> is other than stating its a configuration. Can you provide a simple example of what you are suggesting?<br>
<font color="#888888"><br>
Stephen<br>
</font><div><div></div><div class="h5"><br>
<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</div></div></blockquote></div><br>