[CMake] compiler in not standard path and secondary dependence for shared libraries
David Froger
david.froger.ml at mailoo.org
Thu Aug 27 19:14:05 EDT 2015
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
More information about the CMake
mailing list