[CMake] How to adjust LD_LIBRARY_PATH for an exectubale?

Denis Scherbakov denis_scherbakov at yahoo.com
Wed Mar 25 04:47:52 EDT 2009


Unfortunatelly, the idea with a shell script is not portable.

Here you can see all possible LD_LIBRARY_PATH combinations:
http://www.vtk.org/Wiki/CMake_Platform_Dependent_Issues

Denis


> >> I have an external executable which requires a
> library, which is not in
> >> LD_LIBRARY_PATH. If I manually set
> ENV{LD_LIBRARY_PATH}  and then execute a
> >> command, it works.
> >>
> >> But the problem is that the executable is inside
> ADD_CUSTOM_COMMAND and
> >> even if I set environment variables correctly this
> trick does not work,
> >> because environment is set during CMake run and
> executable is being ran
> >> during gmake run.
> >
> > Maybe you can write a small shell wrapper script which
> sets LD_LIBRARY_PATH
> > and then calls this executable ?
> >
> 
> Something like that works great for me.
> 
> #!/bin/sh
> 
> # This script overload the dynamic library path.
> 
> # Resolve links referring to me.
> if test -L "$0"; then
>     exec $(readlink -f "$0")
> fi
> 



      


More information about the CMake mailing list