如何在 QtCreator 中使用 CMAKE 列出自定义文件?

Adr*_*ire 3 cmake qt-creator

使用CMAKE管理项目时QtCreator,一些有用的文件不会显示在项目浏览器中(例如 xml 文件、.ui 文件等)。

有没有办法使用 显式添加自定义文件以在项目中列出CMAKE

#*************************************************************************
# Indicate a related file for the project, only for convenient showing in
# project, does not mean dependency, inclusion, but just related.
function ("IndicateExternalFile" NAME )
    # TODO: No idea how to make this.

endfunction()
Run Code Online (Sandbox Code Playgroud)

到目前为止尝试:

file( GLOB "test.xml") #Not showing.
Run Code Online (Sandbox Code Playgroud)

Th.*_*ann 7

您可以添加自定义目标并将附加项绑定到该目标。

例子:

add_custom_target(useful_files ALL 
    SOURCES
      MyUsefulFile.txt
      Read.me
      Version.txt
)
Run Code Online (Sandbox Code Playgroud)

我在每个子文件夹中都使用它。QtCreator 在项目列表中显示添加的文件。

顺便说一句:我避免使用file( GLOB ...). 原因请参阅CMake 文档。