<div dir="ltr">It doesn't seem to work.<div><br></div><div>I can't use target_link_libraries on an imported target.</div><div><br></div><div>add_library(imported_lib STATIC IMPORTED GLOBAL)</div><div>set_target_properties(imported_lib PROPERTIES IMPOARTED_LOCATION "${imported_lib_location}")</div>
<div>target_link_libraries(imported_lib other_lib)</div><div><br></div><div>Produces an error:</div><div><br></div><div>Attempt to add link library [imported_lib_location] to target imported_lib which is not built in this directory.</div>
<div><br></div><div>James</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Oct 16, 2013 at 2:12 PM, Robert Maynard <span dir="ltr"><<a href="mailto:robert.maynard@kitware.com" target="_blank">robert.maynard@kitware.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Can you try something like this?<br>
<br>
<a href="https://github.com/robertmaynard/Sandbox/blob/master/ImportedLibrary/CMakeLists.txt" target="_blank">https://github.com/robertmaynard/Sandbox/blob/master/ImportedLibrary/CMakeLists.txt</a><br>
<br>
I don't see the second shared library linking to the imported static library.<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
On Wed, Oct 16, 2013 at 3:44 PM, James Bigler <<a href="mailto:jamesbigler@gmail.com">jamesbigler@gmail.com</a>> wrote:<br>
> On Wed, Oct 16, 2013 at 1:34 PM, Giordano Khouri <<a href="mailto:kgiordano@nikon.net">kgiordano@nikon.net</a>><br>
> wrote:<br>
>><br>
>> The static libraries must be compiled with -fvisibility=hidden. Symbols<br>
>> with default visibility are marked as “public” and will leak from a shared<br>
>> library. With hidden visibility, they symbols are marked as “private<br>
>> extern”, allowing you to link with them, but not allowing them to leak from<br>
>> a shared library. Any time that shared libraries are involved, you will want<br>
>> hidden visibility and mark your public API functions with default<br>
>> visibility.<br>
>><br>
>><br>
>><br>
>><br>
><br>
> That's true, but in my particular case I use a symbol list to control which<br>
> symbols are exported from the shared library. I don't really care what<br>
> visibility the static libraries I link to use, since I specify exactly which<br>
> symbols get exported, and I never export symbols from these external static<br>
> libraries.<br>
><br>
> This isn't really what my issue is though.<br>
><br>
> The problem is that I have a static library which depends on symbols from<br>
> other libraries. Once I create a shared library with that static library I<br>
> don't need to cart around the static library's dependencies anymore, because<br>
> I no longer need to link against the static library.<br>
><br>
> This comes up, because in order to create universal libraries on Mac with<br>
> CUDA, I have to compile the whole library once for 32 bit and once for 64<br>
> bit. I then merge the two libraries into a single library and then use the<br>
> imported library functionality to tell CMake to treat my new merged library<br>
> like any other kind of target. Since I can't use target_link_libraries with<br>
> an imported target, I have to use<br>
> set_target_properties(IMPORTED_LINK_INTERFACE_LIBRARIES). There doesn't<br>
> seem to be a mechanism to deal with the issue of PRIVATE versus PUBLIC<br>
> interfaces, unless I'm mistaken.<br>
><br>
> James<br>
><br>
</div></div><div class="HOEnZb"><div class="h5">> --<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:<br>
> <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<br>
> 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<br>
> <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://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</div></div></blockquote></div><br></div>