Skip to content

Commit

Permalink
style: 函数和宏名称使用小写
Browse files Browse the repository at this point in the history
  • Loading branch information
SongZihuan committed Sep 17, 2021
1 parent ff47bc6 commit 07a9289
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ project(CMakeFindExternalProjectTest C)
message(STATUS "CMAKE_GENERATOR = ${CMAKE_GENERATOR}")

include(cmake/CMakeFindExternalProject/init.cmake)
CFEP_find_git(msgTargets GIT "https://gitee.com/SuperHuan0630/cmake-learn.git" GIT_TAG "main"
cfep_find_git(msgTargets GIT "https://gitee.com/SuperHuan0630/cmake-learn.git" GIT_TAG "main"
EXTERNAL TIMEOUT 60 INSTALL_DIR base)

if (msgTargets_FOUND)
Expand Down
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ xxx可以为`url`,`git`,`dir`分别表示从不同的地方下载第三方

#### 从URL下载项目
```
CFEP_find_url(<name>
cfep_find_url(<name>
[REQUIRE]
[QUIET]
[URL _url]
Expand Down Expand Up @@ -114,7 +114,7 @@ SOURCE_DIR _source_dir
#### 添加到安装目录
将第三方依赖安装到指定位置(随构建树一起安装),使用函数:
```
CFEP_install(<name>
cfep_install(<name>
[NOT_QUIET]
[PREFIX _prefix]
)
Expand All @@ -130,7 +130,7 @@ CFEP_install(<name>
#### 立即复制到指定位置
将第三方依赖安装的内容复制到指定位置(CMake配置时执行),使用函数:
```
CFEP_copy_install(<name>
cfep_copy_install(<name>
[NOT_QUIET]
[DEST _dest]
)
Expand All @@ -150,7 +150,7 @@ CFEP_copy_install(<name>
因为`windows`平台没有`rpath`等机制, 因此需要将第三方导入的库的`.dll`复制到指定位置
使用函数:
```
WI_install_import(
wi_install_import(
[RUNTIME _runtime]
[LIBRARY _library]
[TARGETS ...]
Expand All @@ -161,14 +161,14 @@ WI_install_import(
* `LIBRARY` 导入库的安装位置,默认值为`INSTALL_LIBDIR`
* `TARGETS` 安装的对象

`WI_install_import`是在构建树安装时才安装导入的库。
使用`WI_copy_import`可以在`CMake`配置时就复制文件到指定位置。
使用方式和`WI_install_import`相同。
`wi_install_import`是在构建树安装时才安装导入的库。
使用`wi_copy_import`可以在`CMake`配置时就复制文件到指定位置。
使用方式和`wi_install_import`相同。

#### 安装`.dll`
使用如下函数,可以检索文件夹下的所有`dll`并安装到指定位置:
```
WI_install_dll_bin(
wi_install_dll_bin(
[RUNTIME _runtime]
[DIRS ...]
)
Expand All @@ -177,14 +177,14 @@ WI_install_dll_bin(
* `RUNTIME` 运行时库安装的位置, 默认值为`INSTALL_BINDIR`
* `DIRS` 需要检查的目录路径

`WI_install_dll_bin`是在构建树安装时才安装导入的库。
使用`WI_copy_dll_bin`可以在`CMake`配置时就复制文件到指定位置。
使用方式和`WI_install_dll_bin`相同。
`wi_install_dll_bin`是在构建树安装时才安装导入的库。
使用`wi_copy_dll_bin`可以在`CMake`配置时就复制文件到指定位置。
使用方式和`wi_install_dll_bin`相同。

#### 检查是否包含`.exe`
使用如下函数,检查一个目录是否包含`.exe`,若包含则将该目录的`.dll`安装到指定位置:
```
WI_install_dll_dir(
wi_install_dll_dir(
[RUNTIME _runtime]
[DIRS ...]
)
Expand All @@ -193,16 +193,16 @@ WI_install_dll_dir(
* `RUNTIME` 运行时库安装的位置, 默认值为`INSTALL_BINDIR`
* `DIRS` 需要检查的目录路径

`WI_install_dll_dir`是在构建树安装时才安装导入的库。
使用`WI_copy_dll_dir`可以在`CMake`配置时就复制文件到指定位置。
使用方式和`WI_install_dll_dir`相同。
`wi_install_dll_dir`是在构建树安装时才安装导入的库。
使用`wi_copy_dll_dir`可以在`CMake`配置时就复制文件到指定位置。
使用方式和`wi_install_dll_dir`相同。

### 安装程序
#### 设定安装路径
设定标准的`GNU`安装路径, 使用如下函数:
```
WI_set_install_dir
WI_set_install_dir_quiet
wi_set_install_dir
wi_set_install_dir_quiet
```
以上两个函数的区别在于, 后者不会显示任何信息。
注意:该函数必须在`project`指令后执行。
Expand All @@ -222,7 +222,7 @@ WI_set_install_dir_quiet
#### 使用安装路径安装
使用如下函数安装对象, 该函数和`install`指令类似, 但是使用了预设的安装路径。
```
WI_install(
wi_install(
[INSTALL ...]
[ARCHIVE ...]
[RUNTIME ...]
Expand Down
10 changes: 5 additions & 5 deletions cmake/CMakeFindExternalProject/CMakeFindExternalProject.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ macro(_cfep_found_inline _found)
endmacro()

# 从url下载文件
macro(CFEP_find_url name)
macro(cfep_find_url name)
while (1) # 宏无法处理return, 所以使用while+break来模拟return
set(options REQUIRED QUIET)
set(oneValueArgs URL CMAKE_DIR)
Expand Down Expand Up @@ -369,7 +369,7 @@ macro(CFEP_find_url name)
endmacro()

# 从git下载文件
macro(CFEP_find_git name)
macro(cfep_find_git name)
while (1) # 宏无法处理return, 所以使用while+break来模拟return
set(options REQUIRED QUIET)
set(oneValueArgs GIT GIT_TAG CMAKE_DIR)
Expand Down Expand Up @@ -450,7 +450,7 @@ macro(CFEP_find_git name)
endmacro()

# 从dir下载文件
macro(CFEP_find_dir name)
macro(cfep_find_dir name)
while (1) # 宏无法处理return, 所以使用while+break来模拟return
set(options REQUIRED QUIET)
set(oneValueArgs SOURCE_DIR CMAKE_DIR)
Expand Down Expand Up @@ -528,7 +528,7 @@ macro(CFEP_find_dir name)
endmacro()

# 安装程序
function(CFEP_install name)
function(cfep_install name)
cmake_parse_arguments(ci "NOT_QUIET" "PREFIX" "" ${ARGN})

if (NOT ci_PREFIX)
Expand All @@ -555,7 +555,7 @@ function(CFEP_install name)
set(${name}_CFEP_INSTALL_SUCCESS TRUE PARENT_SCOPE)
endfunction()

function(CFEP_copy_install name)
function(cfep_copy_install name)
cmake_parse_arguments(cci "NOT_QUIET" "DEST" "" ${ARGN})

if (NOT cci_DEST)
Expand Down
6 changes: 3 additions & 3 deletions cmake/CMakeFindExternalProject/InstallDir.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
设置安装路径的程序
]]

function(WI_set_install_dir_quiet)
function(wi_set_install_dir_quiet)
cmake_parse_arguments(i "" "NAMES" "" ${ARGN})

if (i_NAMES)
Expand Down Expand Up @@ -39,7 +39,7 @@ function(WI_set_install_dir_quiet)
unset(DEF_INSTALL_CMAKEDIR)
endfunction()

function(WI_set_install_dir)
function(wi_set_install_dir)
if (NOT CMAKE_SIZEOF_VOID_P) # 如果还未设定CMAKE_SIZEOF_VOID_P, 则现在设定该值
try_run(run_re com_re ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/_void_p_test.c)
if (com_re) # 编译正常
Expand All @@ -48,7 +48,7 @@ function(WI_set_install_dir)
endif()

set(_argn ${ARGN})
WI_set_install_dir_quiet(${_argn})
wi_set_install_dir_quiet(${_argn})

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} PARENT_SCOPE) # 静态库的输出路径
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} PARENT_SCOPE) # 动态库(或者动态库的导入文件)的输出路径
Expand Down
16 changes: 8 additions & 8 deletions cmake/CMakeFindExternalProject/WindowsInstall.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function(_wi_install_import_inline target run lib)
endif()
endfunction()

function(WI_install_import)
function(wi_install_import)
cmake_parse_arguments(ii "" "RUNTIME;LIBRARY" "TARGETS" ${ARGN})
if (NOT ii_RUNTIME)
if (INSTALL_BINDIR)
Expand Down Expand Up @@ -102,7 +102,7 @@ function(_wi_copy_import_inline target run lib)
endif()
endfunction()

function(WI_copy_import)
function(wi_copy_import)
cmake_parse_arguments(ii "" "RUNTIME;LIBRARY" "TARGETS" ${ARGN})
if (NOT ii_RUNTIME)
if (INSTALL_BINDIR)
Expand Down Expand Up @@ -131,7 +131,7 @@ function(WI_copy_import)
endfunction()

# 安装install的bin目录(检查.dll并安装到指定位置)
function(WI_install_dll_bin)
function(wi_install_dll_bin)
if(WIN32)
cmake_parse_arguments(ii "" "RUNTIME" "DIRS" ${ARGN})
if (NOT ii_RUNTIME)
Expand Down Expand Up @@ -159,7 +159,7 @@ function(WI_install_dll_bin)
endfunction()

# 复制bin目录(检查.dll并复制到指定位置)
function(WI_copy_dll_bin)
function(wi_copy_dll_bin)
if(WIN32)
cmake_parse_arguments(ii "" "RUNTIME" "DIRS" ${ARGN})
if (NOT ii_RUNTIME)
Expand Down Expand Up @@ -187,7 +187,7 @@ function(WI_copy_dll_bin)
endfunction()

# 检查文件夹是否有exe, 若有则将其当作bin目录处理
function(WI_install_dll_dir)
function(wi_install_dll_dir)
if(WIN32)
cmake_parse_arguments(ii "" "RUNTIME" "DIRS" ${ARGN})
if (NOT ii_RUNTIME)
Expand All @@ -207,14 +207,14 @@ function(WI_install_dll_dir)
CONFIGURE_DEPENDS
"${dir}/*.exe")
if (_exe)
WI_install_dll_bin(RUNTIME ${runtime} DIRS ${dir})
wi_install_dll_bin(RUNTIME ${runtime} DIRS ${dir})
endif()
endforeach()
endif()
endfunction()

# 检查文件夹是否有exe, 若有则将其当作bin目录处理
function(WI_copy_dll_dir)
function(wi_copy_dll_dir)
if(WIN32)
cmake_parse_arguments(ii "" "RUNTIME" "DIRS" ${ARGN})
if (NOT ii_RUNTIME)
Expand All @@ -234,7 +234,7 @@ function(WI_copy_dll_dir)
CONFIGURE_DEPENDS
"${dir}/*.exe")
if (_exe)
WI_copy_dll_bin(RUNTIME ${runtime} DIRS ${dir})
wi_copy_dll_bin(RUNTIME ${runtime} DIRS ${dir})
endif()
endforeach()
endif()
Expand Down

0 comments on commit 07a9289

Please sign in to comment.