The best way is to use imported targets, specifying different locations for each configuration (<meta http-equiv="content-type" content="text/html; charset=utf-8"><a href="http://www.cmake.org/Wiki/CMake/Tutorials/Exporting_and_Importing_Targets">http://www.cmake.org/Wiki/CMake/Tutorials/Exporting_and_Importing_Targets</a>).<div>
<br></div><div>Or simply use OPTIMIZED and DEBUG keywords in target_link_libraries (see command help).<br><br><div class="gmail_quote">On Tue, May 17, 2011 at 1:42 PM, David Aldrich <span dir="ltr"><<a href="mailto:David.Aldrich@emea.nec.com">David.Aldrich@emea.nec.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div lang="EN-GB" link="blue" vlink="purple"><div><p class="MsoNormal">Hi</p><p class="MsoNormal"> </p><p class="MsoNormal">
My understanding is that cmake will automatically set the compiler flags based on CMAKE_BUILD_TYPE. I am wondering whether there is a clean way of specifying debug / release ‘extra’ libraries such that cmake will select the appropriate library at link time?</p>
<p class="MsoNormal"> </p><p class="MsoNormal">Currently I use this code to link to the open source ‘SystemC’ library:</p><p class="MsoNormal"> </p><p class="MsoNormal">if( USE_SYSTEMC )</p><p class="MsoNormal"> if( CMAKE_BUILD_TYPE STREQUAL "Release" )</p>
<p class="MsoNormal"> target_link_libraries( zodiac ${SYSTEMCLIB_R} )</p><p class="MsoNormal"> endif( CMAKE_BUILD_TYPE STREQUAL "Release" )</p><p class="MsoNormal"> if( CMAKE_BUILD_TYPE STREQUAL "Debug" )</p>
<p class="MsoNormal"> target_link_libraries( zodiac ${SYSTEMCLIB_D} )</p><p class="MsoNormal"> endif( CMAKE_BUILD_TYPE STREQUAL "Debug" )</p><p class="MsoNormal">endif( USE_SYSTEMC )</p><p class="MsoNormal">
</p><p class="MsoNormal">Is there a cleaner way of doing this?</p><p class="MsoNormal"> </p><p class="MsoNormal"><span style="font-size:10.0pt">Best regards</span></p><p class="MsoNormal"><span style="font-size:10.0pt"> </span></p>
<font color="#888888"><p class="MsoNormal"><span style="font-size:10.0pt">David</span></p><p class="MsoNormal"> </p></font></div></div><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></blockquote></div><br></div>