如何设置 CMake 以递归扫描给定目录并确定源文件列表?
我的项目是一个共享库。我有一个类似于这样的文件夹结构:
/
src/ # Source files in an arbitrary tree
include/ # Headers, tree mirrors that of the src/ folder
examples/ # Executable code examples that link against the library
CMakeLists.txt
我希望 CMake 递归扫描src
并include
确定我的项目中的源文件和头文件列表,而不管目录结构如何。我也想避免:
- 用无穷无尽的文件污染
src/
和目录include/
CMakeLists.txt
- 每次更改文件夹结构时都必须更改和调整脚本
但是,每个示例都有自己的构建脚本很好。