<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Aug 7, 2014 at 11:27 AM, Glenn Coombs <span dir="ltr"><<a href="mailto:glenn.coombs@gmail.com" target="_blank">glenn.coombs@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>I just tried reproducing your 2 examples.  Setup 1 works fine for me with no messages about policy CMP0022.  The only way I could get that message produced was by omitting the cmake_minimum_required(VERSION 3.0) line.  Are you sure you're running the exact same CMakeLists.txt file that you have posted here ?<br>
</div></div></div></blockquote><div><br></div><div>Right. I must've messed the copy-paste; I see no cmake warnings either.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div><div>
<br></div>For setup 2 I get the same results as you.  CMake seems to insist on converting the forward slash into a backwards slash, probably because it thinks it is a file path, which totally screws things up.  I suspect this is a bug in cmake: adding linker flags like this works for linux because it doesn't mess with strings like "-Wl,-Bstatic".  The only workaround I can suggest is to set CMAKE_EXE_LINKER_FLAGS:<br>

<br>if (MSVC)<br>        set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /FORCE:Multiple")<br>endif()<br></div></div></blockquote><div><br></div><div>This indeed was my first reaction too, but it's becoming '/FORCE:multiple' specific.<br>
One other use case would be for a library to require a certain symbol to be undefined (-u for LD)<br></div><div>I looked through the sources and there's no INTERFACE_LINK_FLAGS appended when<br>the target construction is done.<br>
<br></div><div>As a work-around I'm setting a variable which is either msvc or gcc specific.<br></div><div>When I get the linker errors, I append the variable to the LINK_FLAGS of the erroneous target <br></div><div><br>
 </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>which correctly adds the option you want but it will do it for all libraries in the current context.  In order to only have it applied to the one library you would need to have a separate CMakeLists.txt for that library and add the lines above to adjust the CMAKE_EXE_LINKER_FLAGS only in that CMakeLists.txt.  Then you would have to do and add_subdirectory(special_lib) somewhere in your higher level CMakeLists.txt.<br>

<br></div><div>--<br></div>Glenn<br><br></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On 3 August 2014 07:43, Adrian M Negreanu <span dir="ltr"><<a href="mailto:groleo@gmail.com" target="_blank">groleo@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>I've tested this with vs 2013 but a few things makes me think<br></div><div>that using target_link_libraries is not for this type of usage.<br>

<br></div><div>First, for setup 1:<br>===== CMakeLists.txt ================<br>
cmake_minimum_required(VERSION 3.0)<div><br>add_library(A a.cpp)<br>target_link_libraries(A INTERFACE -custom-flags)<br><br></div>add_executable(E e.cpp)<br>target_link_libraries(E A)<br>###################################<br>

</div>
<div><br></div><div>Cmake warns me:<br></div><div><br>  CMake Warning (dev) in CMakeLists.txt:<br>  Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link<br>  interface.  Run "cmake --help-policy CMP0022" for policy details.  Use the<br>


  cmake_policy command to set the policy and suppress this warning.<br><br>  Target "A" has an INTERFACE_LINK_LIBRARIES property.  This should be<br>  preferred as the source of the link interface for this library but because<br>


  CMP0022 is not set CMake is ignoring the property and using the link<br>  implementation as the link interface instead.<br><br>  INTERFACE_LINK_LIBRARIES:<br><br>    /FORCE:multiple<br><br></div><div><br>For setup 2:<br>


===== CMakeLists.txt ================<br>cmake_minimum_required(VERSION 3.0)<br>add_library(A a.cpp)<br>set_target_properties(A PROPERTIES INTERFACE_LINK_LIBRARIES "/FORCE:multiple")<br><br>add_executable(E e.cpp)<br>


target_link_libraries(E A)<br>###################################<br><br><br>Cmake works fine, _but_ "/FORCE:multiple" is seen as a file, which leads to error:<br><br>1>------ Build started: Project: ZERO_CHECK, Configuration: Debug Win32 ------<br>


2>------ Build started: Project: A, Configuration: Debug Win32 ------<br>2>  A.vcxproj -> C:\Users\amnegrea\Debug\A.lib<br>3>------ Build started: Project: E, Configuration: Debug Win32 ------<br>3>LINK : fatal error LNK1104: cannot open file '\FORCE:multiple.obj'<br>


4>------ Skipped Build: Project: ALL_BUILD, Configuration: Debug Win32 ------<br>4>Project not selected to build for this solution configuration <br>========== Build: 2 succeeded, 1 failed, 0 up-to-date, 1 skipped ==========<br>


<br></div><div></div><div><br><br></div></div><div class="gmail_extra"><div><div><br><br><div class="gmail_quote">On Sat, Aug 2, 2014 at 7:38 PM, Walter Gray <span dir="ltr"><<a href="mailto:chrysalisx@gmail.com" target="_blank">chrysalisx@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Glen is correct. You should take a look at the docs for interface modules here:</p>
<p dir="ltr"><a href="http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html#interface-libraries" target="_blank">http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html#interface-libraries</a></p>



<p dir="ltr">I also put up some examples of how to do this on github a while back.</p>
<p dir="ltr"><a href="https://github.com/wal-rus/cmake-modules" target="_blank">https://github.com/wal-rus/cmake-modules</a></p>
<p dir="ltr">Hope that helps! Also for future googling the concept is called Usage Requirements.<br>
</p><div><div>
<div class="gmail_quote">On Aug 2, 2014 8:11 AM, "Glenn Coombs" <<a href="mailto:glenn.coombs@gmail.com" target="_blank">glenn.coombs@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div dir="ltr"><div><div>I think that you can use the target_link_libraries command to do this:<br><br>add_library(A a.cpp)<br></div>target_link_libraries(A INTERFACE -custom-flags)<br><br>--<br></div>Glenn<br><br></div>


<div class="gmail_extra">

<br><br><div class="gmail_quote">On 30 July 2014 16:51, Adrian M Negreanu <span dir="ltr"><<a href="mailto:groleo@gmail.com" target="_blank">groleo@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div dir="ltr"><div><div>Hi,<br><br></div>Is it possible to attach a property on a target, and that property<br>to be used whenever the target is used ?<br><br></div><div>ex:<br><br>add_library(A a.cpp)<br></div><div>somehow_attach_LINK_FLAGS(A "--custom-flags")<br>





<br></div><div># in a different directory<br></div><div>add_executable(E e.cpp)<br>target_link_libraries(E A)<br># ^---  this would do something similiar to<br>set_target_properties(E PROPERTIES LINK_FLAGS "--custom-flags")<br>





</div><div><br></div>For example, to use A:LINK_FLAGS<br><div><div><div><br clear="all"><div><div>Thanks<br></div></div></div></div></div></div>
<br>--<br>
<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</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>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" target="_blank">http://cmake.org/cmake/help/training.html</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>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br></blockquote></div><br></div>
<br>--<br>
<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</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>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" target="_blank">http://cmake.org/cmake/help/training.html</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>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br></blockquote></div>
</div></div></blockquote></div><br><br clear="all"><br></div></div><span><font color="#888888">-- <br>Regards!<br><a href="http://groleo.wordpress.com" target="_blank">http://groleo.wordpress.com</a>
</font></span></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Regards!<br><a href="http://groleo.wordpress.com">http://groleo.wordpress.com</a>
</div></div>