<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)<br>add_library(A a.cpp)<br>target_link_libraries(A INTERFACE -custom-flags)<br><br>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"><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 class="HOEnZb"><div class="h5">
<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>-- <br>Regards!<br><a href="http://groleo.wordpress.com">http://groleo.wordpress.com</a>
</div>