测试用例的目录结构
./cmake
|
+--- find_path/
|
+--- CMakeLists.txt
|
+--- test.h
本例中的实际目录为 D:\cmake\find_path
- short-hand signature
find_path( name1 [path1 path2 …])
- 用法1
find_path(TEST_PATH find_path/test.h d:/cmake)
message(${TEST_PATH})
查看CMakeCache.txt中保存的结果为:
//Path to a file.
TEST_PATH:PATH=D:/cmake - 用法2
find_path(TEST_PATH test.h d:/cmake/find_path)
message(${TEST_PATH})
查看CMakeCache.txt中保存的结果为:
//Path to a file.
TEST_PATH:PATH=D:/cmake/find_path
- full-hand signature
find_path(
<VAR>
name | NAMES name1 [name2 ...]
[HINTS path1 [path2 ... ENV var]]
[PATHS path1 [path2 ... ENV var]]
[PATH_SUFFIXES suffix1 [suffix2 ...]]
[DOC "cache documentation string"]
[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]
)
- 用法1
find_path(TEST_PATH NAMES test.h PATHS d:/cmake/find_path DOC "this is a test for find_path")
message(${TEST_PATH})
查看CMakeCache.txt中保存的结果为:
//this is a test for find_path
TEST_PATH:PATH=D:/cmake/find_path - 用法2
//this is a test for find_path
TEST_PATH:PATH=D:/cmake/find_path
其它参数的用法参见CMake文档
网友评论