<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>