Is there a way to specify the shared library path from CMakeLists.txt? I want to make an executable which uses OpenCV but I don't want the final user to install OpenCV. Instead I would like to deliver a folder containing my executable and the shared libraries it needs. The final structure should be something like
Delivery
- MyApp
- OpenCV (folder containing opencv dylibs)
In the end MyApp should search for the shared libs in OpenCV folder. I tried to use the info from https://cmake.org/Wiki/CMake_RPATH_handling but for some reason I don't seem to understand what i really have to do to achieve what I want.
I tried to set CMAKE_INSTALL_RPATH to @loader_path or @executable_path but don't see any change. It still searches for opencv libs in /lib folder.
Running otool -L MyApp results in:
lib/libopencv_imgproc.3.1.dylib (compatibility version 3.1.0, current version 3.1.0) lib/libopencv_imgcodecs.3.1.dylib (compatibility version 3.1.0, current version 3.1.0) lib/libopencv_highgui.3.1.dylib (compatibility version 3.1.0, current version 3.1.0) lib/libopencv_core.3.1.dylib (compatibility version 3.1.0, current version 3.1.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)