diff --git a/CMakeLists.txt b/CMakeLists.txt index 189db91..57b0708 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,10 +4,10 @@ project(LIBMAGTESS VERSION 1.0) # 设置安装地址 if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux") message(STATUS "Platform: " ${CMAKE_HOST_SYSTEM_NAME}) - set(CMAKE_INSTALL_PREFIX /usr/local) + set(CMAKE_INSTALL_PREFIX /opt/stow/magnetic-tesseroids) elseif (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin") message(STATUS "Platform: " ${CMAKE_HOST_SYSTEM_NAME}) - set(CMAKE_INSTALL_PREFIX /opt) + set(CMAKE_INSTALL_PREFIX /opt/stow/magnetic-tesseroids) elseif (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows") message(STATUS "Platform: " ${CMAKE_HOST_SYSTEM_NAME}) # 使用MinGW GCC编译时需取消注释 @@ -16,7 +16,7 @@ elseif (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows") set(CMAKE_INSTALL_PREFIX D:/Library) else() message(STATUS "Platform: " ${CMAKE_HOST_SYSTEM_NAME}) - set(CMAKE_INSTALL_PREFIX /usr/local) + set(CMAKE_INSTALL_PREFIX /opt/stow/magnetic-tesseroids) endif() message(STATUS "Install prefix: " ${CMAKE_INSTALL_PREFIX}) diff --git a/config.sh b/config.sh new file mode 100755 index 0000000..041e014 --- /dev/null +++ b/config.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +cmd=${1} +package=magnetic-tesseroids +address=/opt + +if [[ ${cmd} == "configure" && ! -d "build/" ]]; then + mkdir build && cd build && cmake .. -DCMAKE_INSTALL_PREFIX=${address}/stow/${package} -DCMAKE_BUILD_TYPE=Release +elif [[ ${cmd} == "configure" ]]; then + cd build && rm -rf * && cmake .. -DCMAKE_INSTALL_PREFIX=${address}/stow/${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} +fi \ No newline at end of file diff --git a/toolkits/CMakeLists.txt b/toolkits/CMakeLists.txt index 55811d5..812e7c5 100644 --- a/toolkits/CMakeLists.txt +++ b/toolkits/CMakeLists.txt @@ -25,8 +25,8 @@ macro(add_tools name) set_target_properties(${name} PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib) # 链接动态库 target_link_libraries(${name} PUBLIC magtess) - # 将可执行程序安装到/usr/local/sbin - install(TARGETS ${name} RUNTIME DESTINATION bin/magtess) + # 将可执行程序安装到bin + install(TARGETS ${name} RUNTIME DESTINATION bin) endmacro() # 添加tools @@ -43,5 +43,5 @@ add_executable(tessutil_magnetize_model tessutil_magnetize_model.c) set_target_properties(tessutil_magnetize_model PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib) # 链接动态库 target_link_libraries(tessutil_magnetize_model PUBLIC magtess) -# 将可执行程序安装到/opt/bin -install(TARGETS tessutil_magnetize_model RUNTIME DESTINATION bin/magtess) \ No newline at end of file +# 将可执行程序安装到bin +install(TARGETS tessutil_magnetize_model RUNTIME DESTINATION bin) \ No newline at end of file