From 4733fe57acef151f6ba3bd0bbec9dc4c869e9593 Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Mon, 2 Aug 2021 21:54:09 +0800 Subject: [PATCH] update build system --- config.sh | 9 +++++---- src/CMakeLists.txt | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/config.sh b/config.sh index b55f394..38c308a 100755 --- a/config.sh +++ b/config.sh @@ -2,15 +2,16 @@ cmd=${1} package=liblbfgs -address=/opt +address=/opt/stow +targetdir=/usr/local if [[ ${cmd} == "configure" && ! -d "build/" ]]; then - mkdir build && cd build && cmake .. -DCMAKE_INSTALL_PREFIX=${address}/stow/${package} -DCMAKE_BUILD_TYPE=Release + mkdir build && cd build && cmake .. -DCMAKE_INSTALL_PREFIX=${address}/${package} -DCMAKE_BUILD_TYPE=Release elif [[ ${cmd} == "configure" ]]; then - cd build && rm -rf * && cmake .. -DCMAKE_INSTALL_PREFIX=${address}/stow/${package} -DCMAKE_BUILD_TYPE=Release + cd build && rm -rf * && cmake .. -DCMAKE_INSTALL_PREFIX=${address}/${package} -DCMAKE_BUILD_TYPE=Release elif [[ ${cmd} == "build" ]]; then cd build && make elif [[ ${cmd} == "install" ]]; then cd build && sudo make install - sudo stow --dir=${address}/stow --target=${address} ${package} + sudo stow --dir=${address} --target=${targetdir} ${package} fi \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ebd0638..995c43f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -50,7 +50,7 @@ macro(add_sample name file) # 添加可执行文件 命令行 add_executable(${name} sample/${file}) # 为安装文件添加动态库的搜索地址 在Windows下并没有什么用 直接忽略 - set_target_properties(${name} PROPERTIES INSTALL_RPATH "/opt/lib") + set_target_properties(${name} PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib) # 链接动态库 target_link_libraries(${name} PUBLIC lbfgs) endmacro()