更新时间:2023-02-26 20:34:55
我怎么知道仅查看目标系统根目录?
How can I tell it to look in the target sysroot only?
有一系列CMake变量 CMAKE_FIND_ROOT_PATH_MODE _ *
,可针对不同的CMake命令调整搜索策略:
There is a family of CMake variables CMAKE_FIND_ROOT_PATH_MODE_*
, which adjusts search strategy for different CMake commands:
BOTH 值意味着搜索 target 和 host (构建)路径。当未设置变量时,这也是默认行为。
BOTH value means that both target and host (build) paths are searched. This is also a default behavior, when a variable is not set.
ONLY 值表示仅 target
ONLY value means that only target is searched.
Never 值表示只搜索主机。
变量列表:
CMAKE_FIND_ROOT_PATH_MODE_LIBRARY 影响 find_library()
调用
CMAKE_FIND_ROOT_PATH_MODE_INCLUDE 对 find_path()
和 find_file()
调用
CMAKE_FIND_ROOT_PATH_MODE_PACKAGE 影响 CONFIG 中的 find_package()
>模式(搜索 * Config.cmake
文件时)。
CMAKE_FIND_ROOT_PATH_MODE_PACKAGE affects on find_package()
in CONFIG mode (when *Config.cmake
file is searched).
CMAKE_FIND_ROOT_PATH_MODE_PROGRAM 会影响 find_program()
CMAKE_FIND_ROOT_PATH_MODE_PROGRAM affects on find_program()
call.
通常,具体的 find_package()
调用可能会受到所有这些变量的影响。在搜索库的情况下,通常只设置其中三个即可:
Generally, concrete find_package()
call may be affected by all of these variables. In case of searching libraries, it is usually suffificient to set only 3 of them:
# Search libraries only under *target* paths.
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
$ b
变量 CMAKE_FIND_ROOT_PATH_MODE _ *
通常在工具链文件中设置。
Variables CMAKE_FIND_ROOT_PATH_MODE_*
are normally set in toolchain files.