更新时间:2023-02-03 12:51:17
您可以使用 NO_DEFAULT_PATH
, NO_CMAKE_ENVIRONMENT_PATH
中的一个或多个来指定搜索顺序, NO_CMAKE_PATH
, NO_SYSTEM_ENVIRONMENT_PATH
, NO_CMAKE_SYSTEM_PATH
, CMAKE_FIND_ROOT_PATH_BOTH
, ONLY_CMAKE_FIND_ROOT_PATH
或 NO_CMAKE_FIND_ROOT_PATH
。
You can specify the search order using one or more of NO_DEFAULT_PATH
, NO_CMAKE_ENVIRONMENT_PATH
, NO_CMAKE_PATH
, NO_SYSTEM_ENVIRONMENT_PATH
, NO_CMAKE_SYSTEM_PATH
, CMAKE_FIND_ROOT_PATH_BOTH
, ONLY_CMAKE_FIND_ROOT_PATH
, orNO_CMAKE_FIND_ROOT_PATH
.
从 find_library
:
设计了默认搜索顺序项目可以通过简单地多次调用该命令并使用NO_ *选项来覆盖该命令,即可以覆盖特定的顺序。
The default search order is designed to be most-specific to least-specific for common use cases. Projects may override the order by simply calling the command multiple times and using the NO_* options:
find_library(<VAR> NAMES name PATHS paths... NO_DEFAULT_PATH)
find_library(<VAR> NAMES name)
一旦调用成功,将设置结果变量并将其存储在缓存中,这样就不会再有搜索。
Once one of the calls succeeds the result variable will be set and stored in the cache so that no call will search again.
因此,您可以这样做
FIND_LIBRARY(APRUTIL NAMES "aprutil-1"
PATHS ${PROJECT_SOURCE_DIR}/tools/apr/libs NO_DEFAULT_PATH)