On Tue, Mar 24, 2009 at 2:39 PM, Alexander Neundorf
<[email protected]> wrote:
> On Tuesday 24 March 2009, Denis Scherbakov wrote:
>> Dear CMake Community,
>>
>> 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
appname=$(basename $0 | sed s,\.sh$,,)
dirname=$(dirname $0)
case "$dirname" in
/*)
# nothing to do
;;
*)
dirname="$PWD/$dirname"
;;
esac
paths="$dirname/../@EXTRA_LIBRARIES_DIR@"
LD_LIBRARY_PATH="$paths"
export LD_LIBRARY_PATH
DYLD_LIBRARY_PATH="$paths"
export DYLD_LIBRARY_PATH
exec "$dirname/$appname" $*
--
Nicolas Desprès
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake