This problem is related to MacOS X. I would like to link the lib_xxx library, which is located outside of my build tree in some arbitrary place. It will be located in one place in all systems. By default, CMake will add the dependency as follows:
@executable_path/libwupienginemac.dylib
I would like to know how to change @executable_path to:
The absolute path to the library. I see, for example, the following in otool output
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
@rpath Then I could control the location of lib_xxx using RPATH . I prefer this option.
From the documentation and forums, it looks like this: CMAKE_MACOSX_RPATH should solve the problem and implement option (2). However, CMakeLists.txt below still leads to the @executable_path/libwupienginemac.dylib .
cmake_minimum_required(VERSION 3.1) project(xxx_test) set(CMAKE_MACOSX_RPATH 1) find_library(LIB_XXX lib_xxx PATHS "/path/to/lib_xxx/lib" ) if (NOT LIB_XXX) message(FATAL_ERROR ""LIB XXX not found") endif() add_executable(xxx_test xxx_test.cpp) target_link_libraries(xxx_test ${LIB_XXX} ) # Try running the executable at once add_custom_target(wibut_test_run ALL COMMAND xxx_test DEPENDS xxx_test )
source share