Hello,

When linking an executable with a library `libfoo.so` that depedent on a library
`libbar.so` in a non standard directory, flag `-Wl,-rpath-link=...` is required
so that `ld` can find `libar.so`.

It works well with /usr/bin/gcc and libraries somewhere in a non standard
directory, CMake uses the flag `-Wl,-rpath-link`.

But in this case:
    /path/to/somewhere/bin/gcc
    /path/to/somewhere/lib/libfoo.so
    /path/to/somewhere/lib/libbar.so

and with /path/to/somewhere/bin in the PATH, without setting LD_LIBRARY_PATH,
CMake drops the flag `-Wl,-rpath-link=...` and the build fails.

My context is using the Conda package manager. GCC, CMake and ITK are installed
in a Conda environment (which is in the PATH), and the user want to link with
ITK libraries.

I would like to fix the problem without requiring user's "hack", for example
setting LD_LIBRARY_PATH or -DCMAKE_EXE_LINKER_FLAGS.

Any idea?

I have this "foo bar" example to reproduce the problem:

    https://github.com/dfroger/secondary_dep

Thanks,
David
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to