[CMake] RPATH for external library

Pawel Veselov pawel.veselov at gmail.com
Tue May 16 14:50:47 EDT 2017


>> I'm trying to make CMake add to the linker RPATH automatically.
>> There is a library that is installed in a non-default location.
>> I'm discovering the library using PkgConfig (custom
>> CMAKE_APPBUNDLE_PATH) and add the library build options to the
>> LINK_FLAGS (using set_property).
> Instead of setting the LINK_FLAGS to your external library try using
> target_link_libraries() with the full path name to the library.
>
> For example this will work as expected, cmake with set an RPATH
> to "/path/to":
>
>   set(LIB "/path/to/libsomething.so")
>   target_link_libraries(test1 ${LIB})

That doesn't really play well with FindPkgConfig then. AFAIK, there is
no way to ask pkg-config to dish out full libraries paths, one would
have to sift through all -l and -L and figure them out...

Thank you,
  Pawel.


More information about the CMake mailing list