How to make CMake embed library path of imported t

2019-05-18 21:27发布

My C++ executable depends on boost regex which i have imported explicitly. However, during link phase, CMake doesnt use -Wl,-rpath,/path/to/my/boost/lib to embed the rpath in my project executable. How can i acheive that? It does embed rpath to libutils.so, which I also build in my CMakeLists.txt. I am using cmake version 3.9

add_library(boost_regex SHARED IMPORTED GLOBAL)
set_target_properties(boost_regex PROPERTIES IMPORTED_LOCATION ${Boost_REGEX_LIBRARY})

add_library(utils SHARED utils.cpp)
target_link_libraries(utils INTERFACE boost_regex)

add_executable(main main.cpp)
target_link_libraries(main utils)

[100%] Linking CXX executable main cd /home/rajatgirotra/study/cmakeTutorial/sample_ultimate/cmake-build-debug/src/main && /usr/local/bin/cmake -E cmake_link_script CMakeFiles/main.dir/link.txt --verbose=1 /home/rajatgirotra/tools/miniconda2/envs/shriram/bin/c++ -std=c++17 -g CMakeFiles/main.dir/main.cpp.o -o main -Wl,-rpath,/home/rajatgirotra/study/cmakeTutorial/sample_ultimate/cmake-build-debug/src/common ../common/libutils.so /home/rajatgirotra/tools/miniconda2/envs/shriram/lib/libboost_regex.so

标签: c++ boost cmake
0条回答
登录 后发表回答