<html><head></head><body>Hi,<br>
<br>
is the netcdf find module defining an imported target? AFAIK, imported targets are always linked by full path. Else the rules already mentioned apply.<br>
<br>
HS<br>
<br><br><div class="gmail_quote">Am 28. August 2015 10:23:47 MESZ, schrieb "Nico Schlömer" <nico.schloemer@gmail.com>:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div dir="ltr">Hi everyone,<div><br /></div><div>I'm curious about when CMake decides to link a library by its absolute path and when it links using the `-l*` syntax. I came across this for the very simple test problem</div><div>```</div><div><div>cmake_minimum_required(VERSION 3.0)</div><div><br /></div><div>project(mytest)</div><div><br /></div><div>find_package(ZLIB REQUIRED)</div><div>find_package(netCDF REQUIRED)</div><div><br /></div><div>add_executable(mytest main.cpp)</div><div>target_link_libraries(</div><div>  mytest</div><div>  ${ZLIB_LIBRARIES}</div><div>  ${netCDF_LIBRARIES}</div><div>  )</div></div><div>```</div><div>The resulting link line is</div><div>```</div><div><div>/usr/bin/c++       CMakeFiles/mytest.dir/main.cpp.o  -o mytest -rdynamic -lz /usr/lib/x86_64-linux-gnu/libnetcdf.so.7.3.0 </div></div><div>```</div><div>so ZLIB is linked with `-lz`, netCDF with the full absolute path.</div><div><br /></div><div>Seems inconsistent? (ZLIB by the way is
found through CMake's FindZLIB.cmake, netCDF by their own export files.)</div><div><br /></div><div>So far, I had been under the impression that `-l*` defeats the purpose of CMake a little bit as it asks the linker to search in the system's paths for a libz.so, something CMake has already done.</div><div><br /></div><div>A little clarification here would be great.</div><div><br /></div><div>Cheers,</div><div>Nico</div></div>
<p style="margin-top: 2.5em; margin-bottom: 1em; border-bottom: 1px solid #000"></p><pre class="k9mail">-- <br /><br />Powered by <a href="http://www.kitware.com">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">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">http://cmake.org/cmake/help/support.html</a><br />CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html">http://cmake.org/cmake/help/consulting.html</a><br />CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html">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">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">http://public.kitware.com/mailman/listinfo/cmake</a></pre></blockquote></div></body></html>