<div dir="ltr">ADD_SUBDIRECTORY is the &quot;right&quot; thing to be using. SUBDIRS is deprecated, but they process things subtly differently, so I just wanted to rule out that you might be encountering a &quot;SUBDIRS side effect&quot;...<div>
<br></div><div>You&#39;ve ruled it out.<br><br></div><div>Could you re-organize such that libraries with different flags are in different CMakeLists files?</div><div><br></div><div><br><div class="gmail_quote">On Mon, Sep 8, 2008 at 3:02 AM, Martin Apel <span dir="ltr">&lt;<a href="mailto:martin.apel@simpack.de">martin.apel@simpack.de</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">I am using ADD_SUBDIRECTORY. I did&#39;nt know, that anything like SUBDIRS<br>
exists and haven&#39;t found anything in the documentation about it.<br>
<br>
Martin<br>
<div class="Ih2E3d"><br>
<br>
David Cole wrote:<br>
&gt; Are you using SUBDIRS or ADD_SUBDIRECTORY in your project...?<br>
&gt;<br>
&gt;<br>
&gt; On Thu, Sep 4, 2008 at 2:42 AM, Martin Apel &lt;<a href="mailto:martin.apel@simpack.de">martin.apel@simpack.de</a><br>
</div><div><div></div><div class="Wj3C7c">&gt; &lt;mailto:<a href="mailto:martin.apel@simpack.de">martin.apel@simpack.de</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt; &nbsp; &nbsp; Unfortunately this does not work. It seems that CMake generates all<br>
&gt; &nbsp; &nbsp; libraries defined in one CMakeLists.txt with the setting of<br>
&gt; &nbsp; &nbsp; CMAKE_SHARED_LINKER_FLAGS at the end of the file.<br>
&gt; &nbsp; &nbsp; This causes this setting to be applied to all libraries in the<br>
&gt; &nbsp; &nbsp; CMakeLists.txt. As I have 4 libraries in this one CMakeLists.txt, this<br>
&gt; &nbsp; &nbsp; doesn&#39;t help much.<br>
&gt;<br>
&gt; &nbsp; &nbsp; I tried to do something like the following:<br>
&gt; &nbsp; &nbsp; SET (CMAKE_SHARED_LINKER_FLAGS &quot;${ORIG_SHARED_LINKER_FLAGS}&quot;)<br>
&gt; &nbsp; &nbsp; ADD_LIBRARY (FortranInterface ${OBJS})<br>
&gt; &nbsp; &nbsp; SET (CMAKE_SHARED_LINKER_FLAGS &quot;${MODIFIED_SHARED_LINKER_FLAGS}&quot;)<br>
&gt; &nbsp; &nbsp; but the FortranInterface library gets built with<br>
&gt; &nbsp; &nbsp; MODIFIED_SHARED_LINKER_FLAGS in effect.<br>
&gt;<br>
&gt; &nbsp; &nbsp; I would suggest to change the order of items in the build rules for a<br>
&gt; &nbsp; &nbsp; future CMake release, such that it&#39;s possible to override general<br>
&gt; &nbsp; &nbsp; flags<br>
&gt; &nbsp; &nbsp; with a target specific property. Today the link<br>
&gt; &nbsp; &nbsp; rules look as follows:<br>
&gt; &nbsp; &nbsp; SET(CMAKE_CXX_CREATE_SHARED_LIBRARY &quot;&lt;CMAKE_CXX_COMPILER&gt; ...<br>
&gt; &nbsp; &nbsp; &lt;LINK_FLAGS&gt; &lt;CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS&gt; ....&quot;)<br>
&gt; &nbsp; &nbsp; &gt;From my point of view it would be better to put LINK_FLAGS to the<br>
&gt; &nbsp; &nbsp; end of<br>
&gt; &nbsp; &nbsp; the list (not only for shared libraries, but in general).<br>
&gt;<br>
&gt; &nbsp; &nbsp; Regards,<br>
&gt;<br>
&gt; &nbsp; &nbsp; Martin<br>
&gt;<br>
&gt; &nbsp; &nbsp; David Cole wrote:<br>
&gt; &nbsp; &nbsp; &gt; Maybe save and restore the CMAKE_SHARED_LINKER_FLAGS around your<br>
&gt; &nbsp; &nbsp; reset<br>
&gt; &nbsp; &nbsp; &gt; of it in the sub-CMakeLists.txt...?<br>
&gt; &nbsp; &nbsp; &gt;<br>
&gt; &nbsp; &nbsp; &gt;<br>
&gt; &nbsp; &nbsp; &gt; On Wed, Sep 3, 2008 at 10:41 AM, Martin Apel<br>
&gt; &nbsp; &nbsp; &lt;<a href="mailto:martin.apel@simpack.de">martin.apel@simpack.de</a> &lt;mailto:<a href="mailto:martin.apel@simpack.de">martin.apel@simpack.de</a>&gt;<br>
</div></div>&gt; &nbsp; &nbsp; &gt; &lt;mailto:<a href="mailto:martin.apel@simpack.de">martin.apel@simpack.de</a> &lt;mailto:<a href="mailto:martin.apel@simpack.de">martin.apel@simpack.de</a>&gt;&gt;&gt;<br>
<div><div></div><div class="Wj3C7c">&gt; &nbsp; &nbsp; wrote:<br>
&gt; &nbsp; &nbsp; &gt;<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; Hi,<br>
&gt; &nbsp; &nbsp; &gt;<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; I have defined the following in a top-level CMakeLists.txt:<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; &nbsp;SET (CMAKE_SHARED_LINKER_FLAGS &quot;${CMAKE_SHARED_LINKER_FLAGS}<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; -Wl,--unresolved-symbols=ignore-in-shared-libs&quot;)<br>
&gt; &nbsp; &nbsp; &gt;<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; Now I&#39;d like to reset this for one specific library in a<br>
&gt; &nbsp; &nbsp; subdirectory<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; (in a separate CMakeLists.txt added with ADD_SUBDIRECTORY to<br>
&gt; &nbsp; &nbsp; the main<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; CMakeLists.txt). I tried to use<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; &nbsp;SET_TARGET_PROPERTIES (FortranInterface PROPERTIES LINK_FLAGS<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; -Wl,--unresolved-symbols=ignore-in-object-files&quot;)<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; which reverses the effect of &quot;ignore-in-shared-libs&quot;.<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; Unfortunately the<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; linker rule contains the LINK_FLAGS before<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; CMAKE_SHARED_LINKER_FLAGS, so<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; this cannot be used to override the setting. I have also tried<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; resetting<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; CMAKE_SHARED_LINKER_FLAGS in the sub-CMakeLists.txt, but then it<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; applies<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; to all other<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; libraries handled in this CMakeLists.txt as well.<br>
&gt; &nbsp; &nbsp; &gt;<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; Any ideas, how I can solve this problem?<br>
&gt; &nbsp; &nbsp; &gt;<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; Regards,<br>
&gt; &nbsp; &nbsp; &gt;<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; Martin<br>
&gt; &nbsp; &nbsp; &gt;<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; ____________<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; Virus checked by G DATA AntiVirus<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; Version: AVF 19.21 from 03.09.2008<br>
&gt; &nbsp; &nbsp; &gt;<br>
&gt; &nbsp; &nbsp; &gt;<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; _______________________________________________<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; CMake mailing list<br>
&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; <a href="mailto:CMake@cmake.org">CMake@cmake.org</a> &lt;mailto:<a href="mailto:CMake@cmake.org">CMake@cmake.org</a>&gt;<br>
</div></div>&gt; &nbsp; &nbsp; &lt;mailto:<a href="mailto:CMake@cmake.org">CMake@cmake.org</a> &lt;mailto:<a href="mailto:CMake@cmake.org">CMake@cmake.org</a>&gt;&gt;<br>
<div class="Ih2E3d">&gt; &nbsp; &nbsp; &gt; &nbsp; &nbsp; <a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
&gt; &nbsp; &nbsp; &gt;<br>
&gt; &nbsp; &nbsp; &gt;<br>
&gt;<br>
&gt;<br>
&gt; &nbsp; &nbsp; --<br>
&gt;<br>
&gt; &nbsp; &nbsp; Martin Apel &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Tel: &nbsp; &nbsp; 0049 8153<br>
&gt; &nbsp; &nbsp; 9288-47<br>
&gt; &nbsp; &nbsp; Software Architect &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;E-Mail:<br>
</div>&gt; &nbsp; &nbsp; &nbsp;<a href="mailto:martin.apel@simpack.de">martin.apel@simpack.de</a> &lt;mailto:<a href="mailto:martin.apel@simpack.de">martin.apel@simpack.de</a>&gt;<br>
<div class="Ih2E3d">&gt;<br>
&gt; &nbsp; &nbsp; INTEC GmbH &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Tel: &nbsp; &nbsp; 0049 8153<br>
&gt; &nbsp; &nbsp; 9288-0<br>
&gt; &nbsp; &nbsp; Argelsrieder Feld 13 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Fax: &nbsp; &nbsp; 0049 8153<br>
&gt; &nbsp; &nbsp; 9288-11<br>
&gt; &nbsp; &nbsp; 82234 Wessling &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;E-Mail:<br>
</div>&gt; &nbsp; &nbsp; &nbsp;<a href="mailto:intec@simpack.de">intec@simpack.de</a> &lt;mailto:<a href="mailto:intec@simpack.de">intec@simpack.de</a>&gt;<br>
<div class="Ih2E3d">&gt; &nbsp; &nbsp; Germany &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; URL:<br>
&gt; &nbsp; &nbsp; <a href="http://www.simpack.com" target="_blank">http://www.simpack.com</a><br>
&gt;<br>
&gt; &nbsp; &nbsp; ____________<br>
&gt; &nbsp; &nbsp; Virus checked by G DATA AntiVirus<br>
&gt; &nbsp; &nbsp; Version: AVF 19.22 from 03.09.2008<br>
&gt;<br>
&gt;<br>
&gt;<br>
<br>
<br>
</div><div class="Ih2E3d">____________<br>
Virus checked by G DATA AntiVirus<br>
</div>Version: AVF 19.27 from 07.09.2008<br>
<br>
<br>
</blockquote></div><br></div></div>