目录
一 aux_source_directory 概述
aux_source_directory
是一个 CMake 命令,用于将指定目录下的所有源文件列表赋值给一个变量。这个命令在旧版本的 CMake 中常被使用,但近年来 CMake 的最佳实践有所变化,因此该命令的使用已经不那么普遍了。
这个命令的基本语法是:
aux_source_directory(<dir> <variable>) |
<dir>
是要搜索的目录。<variable>
是将存储找到的源文件列表的变量名。
例如:
aux_source_directory(. SRC_LIST) |
|
add_executable(my_program ${SRC_LIST}) |
在这个例子中,aux_source_directory
会搜索当前目录(.
)中的所有源文件,并将它们存储在 SRC_LIST
变量中。然后,这个变量被用作 add_executable
命令的参数,以构建名为 my_program