Browse Source

feat: 添加InstallDir模块

SongZihuan 3 years ago
parent
commit
5606f87784

+ 2 - 2
LICENSE

@@ -21,8 +21,8 @@ subject to the following conditions:
    (or development team) of the software shall appoint a court or arbitration institution to make a ruling.
 
 5. When there is a copyright dispute between other software using the software and the software, the
-   first developer (or developer) of the software shall appoint a court or arbitration institution to
-   make a ruling.
+   first developer (or development team) of the software shall appoint a court or arbitration institution
+   to make a ruling.
 
 DERIVATIVE SOFTWARE REFERS TO NEW SOFTWARE THAT IS RECOMPILED, RELEASED, DISTRIBUTED, AND SOLD AFTER
 MODIFYING THE SOURCE CODE OF THIS SOFTWARE.

+ 2 - 0
README

@@ -17,6 +17,8 @@ WI_install_dll_bin 检查bin目录中的dll, 并添加install
 WI_copy_dll_bin 检查bin目录中的dll, 并复制到指定目录
 WI_install_dll_dir 检查文件夹是否有exe, 若有则将其当作bin目录处理 (WI_install_dll_bin)
 WI_copy_dll_dir 检查文件夹是否有exe, 若有则将其当作bin目录处理 (WI_copy_dll_bin)
+WI_set_install_dir_quiet 设置安装路径
+WI_set_install_dir 设置安装路径并报告
 
 注意: 其余函数和宏均为内部函数, 不建议直接调用
 

+ 37 - 0
cmake/CMakeFindExternalProject/InstallDir.cmake

@@ -0,0 +1,37 @@
+#[[
+文件名: InstallDir.cmake
+设置安装路径的程序
+]]
+
+macro(WI_set_install_dir_quiet)
+    include(GNUInstallDirs)
+    set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY  # 静态库的输出路径
+        ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
+    set(CMAKE_LIBRARY_OUTPUT_DIRECTORY  # 动态库(或者动态库的导入文件)的输出路径
+        ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
+    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
+        ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})  # 可执行文件(以及.dll)的输出路径
+
+    # 设定安装的目录
+    set(INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Installation directory for libraries")
+    set(INSTALL_BINDIR ${CMAKE_INSTALL_BINDIR} CACHE PATH "Installation directory for executables")
+    set(INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} CACHE PATH "Installation directory for header files")
+    set(INSTALL_RESOURCEDIR resource/${PROJECT_NAME} CACHE PATH "Installation directory for resource files")  # 关联文件
+
+    if(WIN32 AND NOT CYGWIN)
+        set(DEF_INSTALL_CMAKEDIR cmake)
+    else()
+        set(DEF_INSTALL_CMAKEDIR share/cmake/${PROJECT_NAME})  # unix类系统(Unix, Linux, MacOS, Cygwin等)把cmake文件安装到指定的系统的cmake文件夹中
+    endif()
+    set(INSTALL_CMAKEDIR ${DEF_INSTALL_CMAKEDIR} CACHE PATH "Installation directory for CMake files")
+    unset(DEF_INSTALL_CMAKEDIR)
+endmacro()
+
+macro(WI_set_install_dir)
+    WI_set_install_dir_quiet()
+
+    # 报告安装路径
+    foreach(p LIB BIN INCLUDE RESOURCE CMAKE)
+        message(STATUS "Installing ${CMAKE_INSTALL_PREFIX}/${INSTALL_${p}DIR}")
+    endforeach()
+endmacro()

+ 37 - 0
cmake/CMakeFindExternalProject/LICENSE

@@ -0,0 +1,37 @@
+HUAN LICENSE
+
+Copyright (c) 2021 SuperHuan
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
+associated documentation files (the “Software”), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+1. Neither the name of the copyright holder nor the names of its contributors may be used to endorse
+   or promote products derived from this software without specific prior written permission.
+
+2. Derivative open source software must be released under the same agreement, and its modified code
+   must be made public.
+
+3. The above copyright notice and this permission notice shall be included in all copies or substantial
+   portions of the Software.
+
+4. When there is a copyright dispute between derivative software and the software, the first developer
+   (or development team) of the software shall appoint a court or arbitration institution to make a ruling.
+
+5. When there is a copyright dispute between other software using the software and the software, the
+   first developer (or development team) of the software shall appoint a court or arbitration institution
+   to make a ruling.
+
+DERIVATIVE SOFTWARE REFERS TO NEW SOFTWARE THAT IS RECOMPILED, RELEASED, DISTRIBUTED, AND SOLD AFTER
+MODIFYING THE SOURCE CODE OF THIS SOFTWARE.
+
+THE NORMAL COMPILATION AND LINKING OF THE LIBRARY BY OTHER SOFTWARE (INCLUDING STATIC LINKING AND DYNAMIC
+LINKING) DOES NOT BELONG TO DERIVATIVE SOFTWARE.
+
+THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
+LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

+ 2 - 1
cmake/CMakeFindExternalProject/init.cmake

@@ -1,2 +1,3 @@
 include(${CMAKE_CURRENT_LIST_DIR}/CMakeFindExternalProject.cmake)
-include(${CMAKE_CURRENT_LIST_DIR}/WindowsInstall.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/WindowsInstall.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/InstallDir.cmake)

+ 2 - 2
cmake/README

@@ -7,6 +7,6 @@ CMakeFindExternalProject.cmake
 CMakeLists.txt.in
 WindowsInstall.cmake
 
-init.cmake 导入 CMakeFindExternalProject.cmake 和 WindowsInstall.cmake
+init.cmake 导入 CMakeFindExternalProject.cmake, WindowsInstall.cmake, InstallDir.cmake
 CMakeFindExternalProject.cmake 依赖于 CMakeLists.txt.in
-WindowsInstall.cmake 与 CMakeFindExternalProject.cmake 无相互依赖
+WindowsInstall.cmake, InstallDir.cmake 和 CMakeFindExternalProject.cmake 之间无相互依赖