Geode-solutions / OpenGeode

Open source framework for representing and manipulating geometric models
https://geode-solutions.com/opengeode
MIT License
148 stars 10 forks source link

fix(CMake): wrong RPATH for executables after install #900

Closed yo35 closed 6 months ago

yo35 commented 6 months ago

When creating an executable with add_geode_binary, if this executable links a lib created in the same CMake project AND is configured to be installed to a custom directory, it does not work after install.

Example with the attached reproducer:

cmake .. -DCMAKE_INSTALL_PREFIX=/path/to/install/dir -DCMAKE_PREFIX_PATH=/path/to/geode
make
./bin/reproducer    # OK
make install
/path/to/install/dir/bin/reproducer    # error while loading shared libraries...

Checking the RUNPATH header in the binaries explains this behavior:

objdump -x ./bin/reproducer | grep RUNPATH
# RUNPATH    $ORIGIN/../lib:
objdump -x /path/to/install/dir/bin/reproducer | grep RUNPATH
# RUNPATH    /../lib

-> the 2nd RUNPATH is invalid.

yo35 commented 6 months ago

reproducer-wrong-rpath.zip

BotellaA commented 6 months ago

It will be included in the next release! Thanks for your feedback!!

yo35 commented 6 months ago

Thanks @BotellaA