CMake IDE 集成:查询源文件列表

CMake IDE integration: Query list of source files

我一直在看 CMake IDE integration guide。 我期望的一个功能是能够查询目标的源文件列表(例如,添加到 target_sources() 的文件列表)。但是,该指南没有提到类似的内容。

观察其他 IDE(例如 JetBrain 的 CLion)时,它似乎支持该功能,因为使用 target_sources() 添加到目标的源标有蓝色小方块。

有什么方法可以通过cmake二进制文件查询目标的源文件列表吗?基本上我想检索 SOURCES target property.

自版本 3.14 以来,CMake 提供了 cmake-file-api to query a buildsystems information. It replaces the CMake server mode which is still supported in current version (CMake 3.19 as of writing). The following codemodel-version-2-target-object 似乎适合您查询目标来源的任务。