Last active
May 7, 2020 07:11
-
-
Save robertmaynard/5750737 to your computer and use it in GitHub Desktop.
CMake RPath Support Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 2.8.12) | |
project(OSXRPath) | |
# enable @rpath in the install name for any shared library being built | |
set(CMAKE_MACOSX_RPATH 1) | |
# add a shared library | |
add_library(foo SHARED foo.cpp) | |
# use the shared library | |
# note: CMake will add an RPATH to this executable which is the absolute location of libfoo.dylib in the build tree. | |
add_executable(bar bar.cpp) | |
# installation | |
install(TARGETS foo DESTINATION lib) | |
install(TARGETS bar DESTINATION bin) | |
# the install RPATH for bar to find foo in the install tree. | |
# if the install RPATH is not provided, the install bar will have none | |
set_target_properties(bar PROPERTIES INSTALL_RPATH "@loader_path/../lib") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment