[CMake] linking: absolute path vs -l<libname>

Alexander Neundorf a.neundorf-work at gmx.net
Thu Sep 3 15:19:33 EDT 2015


On Wednesday, September 02, 2015 22:12:39 Nico Schlömer wrote:
> Indeed,
> ```
> get_target_property(out ${netCDF_LIBRARIES} LOCATION)
> message(${out})
> ```
> gives
> ```
> /usr/lib/x86_64-linux-gnu/libnetcdf.so.7.3.0
> ```
> This value appears to be set in the CMake export file
> ```
> /usr/lib/x86_64-linux-gnu/cmake/netCDF/netCDFTargets-none.cmake
> ```
> What does this mean?

this means that netcdf is a so-called "imported target".
I.e. for cmake, it is a library target, as those which are created when doing 
add_library(foo foo.c bar.c blub.b),
but hass not been built by the project, but has been built and installed 
before, and then during find_package() an "imported" target has been set up, 
which has all necessary target properties set so it can be used the same way a 
target which has been built inside cmake.

Maybe absolute paths of imported targets are handled differently, I'm not 
sure.

Alex



More information about the CMake mailing list