From 065edf8dfd7d9dbf64eb749604193a5027c167b9 Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Sun, 1 Aug 2021 08:29:16 +0800 Subject: [PATCH 1/2] update build system --- CMakeLists.txt | 9 +++++---- config.sh | 16 ++++++++++++++++ lib/CMakeLists.txt | 2 +- toolkits/CMakeLists.txt | 4 ++-- 4 files changed, 24 insertions(+), 7 deletions(-) create mode 100755 config.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index a75d034..cd1e058 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,11 +4,12 @@ project(LIBTESS VERSION 1.6) # 设置安装地址 if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux") message(STATUS "Platform: " ${CMAKE_HOST_SYSTEM_NAME}) - set(CMAKE_INSTALL_PREFIX /usr/local) + # 安装到stow目录 + set(CMAKE_INSTALL_PREFIX /opt/stow/tesseroids) elseif (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin") message(STATUS "Platform: " ${CMAKE_HOST_SYSTEM_NAME}) - # 安装到系统级用户软件目录 - set(CMAKE_INSTALL_PREFIX /opt) + # 安装到stow目录 + set(CMAKE_INSTALL_PREFIX /opt/stow/tesseroids) elseif (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows") message(STATUS "Platform: " ${CMAKE_HOST_SYSTEM_NAME}) # 使用MinGW GCC编译时需取消注释 @@ -17,7 +18,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/tesseroids) endif() message(STATUS "Install prefix: " ${CMAKE_INSTALL_PREFIX}) diff --git a/config.sh b/config.sh new file mode 100755 index 0000000..572a0fe --- /dev/null +++ b/config.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +cmd=${1} +package=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 + stow --dir=${address}/stow --target=${address} ${package} +fi \ No newline at end of file diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index cfe97f4..7d0563e 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -50,5 +50,5 @@ endif() # 头文件安装命令 file(GLOB LIBTESS_HEAD *.h) -# 安装到/opt/include/tess +# 安装到include/tess install(FILES ${LIBTESS_HEAD} DESTINATION include/tess) \ No newline at end of file diff --git a/toolkits/CMakeLists.txt b/toolkits/CMakeLists.txt index 4453479..cf9b7d9 100644 --- a/toolkits/CMakeLists.txt +++ b/toolkits/CMakeLists.txt @@ -22,8 +22,8 @@ macro(add_tools name) set_target_properties(${name} PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib) # 链接动态库 target_link_libraries(${name} PUBLIC tess) - # 将可执行程序安装到/opt/bin/tess - install(TARGETS ${name} RUNTIME DESTINATION bin/tess) + # 将可执行程序安装到bin + install(TARGETS ${name} RUNTIME DESTINATION bin) endmacro() # 添加tools From 73abd077db07baa6a28a046363717abd02ce4822 Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Sun, 1 Aug 2021 08:34:25 +0800 Subject: [PATCH 2/2] update build system --- config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.sh b/config.sh index 572a0fe..00d3dde 100755 --- a/config.sh +++ b/config.sh @@ -12,5 +12,5 @@ elif [[ ${cmd} == "build" ]]; then cd build && make elif [[ ${cmd} == "install" ]]; then cd build && sudo make install - stow --dir=${address}/stow --target=${address} ${package} + sudo stow --dir=${address}/stow --target=${address} ${package} fi \ No newline at end of file