更新时间:2022-05-23 23:47:38
cmake
是否有标准位置来查找.cmake
脚本?
Does
cmake
have a standard location to look for.cmake
scripts?
对于 execute_process
,否。 find_XXX
命令(例如> find_file
)和 include
可以。
For execute_process
, no. The find_XXX
commands (e.g. find_file
) and include
do though.
我是否可以定义
cmake
变量来告诉cmake
在哪里查看?
Is there a
cmake
variable I can define to tellcmake
where to look?
再次,对于 execute_process
,否 find_xxx
或 include
,您可以设置变量 CMAKE_MODULE_PATH
。
Again, for execute_process
, no. For find_xxx
or include
, you can set the variable CMAKE_MODULE_PATH
.
我应该始终给出脚本的完整路径(即
-P $ {PATH_VAR} /myScript.cmake
) ?
这是一个不错的选择;通过完整的路径不会有不确定的余地,但是,您也可以摆脱相对路径。 execute_process
的默认工作目录是 CMAKE_BINARY_DIR
,因此您可以相对于脚本传递路径。
That's a good option; passing a full path leaves no room for uncertainty. However, you can get away with a relative path too. The default working directory for execute_process
is the CMAKE_BINARY_DIR
, so you can pass the path to the script relative to that.
或者,您可以在 execute_process
调用中指定 WORKING_DIRECTORY
作为完整路径或相对于 CMAKE_BINARY_DIR
。
Alternatively you can specify the WORKING_DIRECTORY
in the execute_process
call either as a full path or relative to the CMAKE_BINARY_DIR
.
如果您认为脚本位于标准位置,则可以考虑先使用 find_file
。这将找到脚本的完整路径,并且可以在您的 execute_process
调用中使用该变量。
If you feel your script is in a standard location, you could consider "finding" it first using a call to find_file
. This would yield the full path to the script if found and that variable can be used in your execute_process
call.
【Android NDK 开发】Android Studio 使用 CMake 导入动态库 ( 构建脚本路径配置 | 指定动态库查找路径 | 链接动态库 )(二)
【Android FFMPEG 开发】Android Studio 工程配置 FFMPEG ( 动态库打包 | 头文件与函数库拷贝 | CMake 脚本配置 )(二)
【Android NDK 开发】Android Studio 的 NDK 配置 ( 源码编译配置 | 构建脚本配置 | 打包配置 | CMake 配置 | ndkBuild 配置 )(一)
【Android NDK 开发】Android Studio 的 NDK 配置 ( 源码编译配置 | 构建脚本配置 | 打包配置 | CMake 配置 | ndkBuild 配置 )(二)
【Android FFMPEG 开发】Android Studio 工程配置 FFMPEG ( 动态库打包 | 头文件与函数库拷贝 | CMake 脚本配置 )(一)
【Android NDK 开发】Android Studio 使用 CMake 导入静态库 ( CMake 简介 | 构建脚本路径配置 | 引入静态库 | 指定静态库路径 | 链接动态库 )(一)