gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 15:11:53 24 4
gpt4 key购买 nike

使用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()

到目前为止的尝试:

file( GLOB "test.xml") #Not showing.

最佳答案

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

例子:

add_custom_target(useful_files ALL 
SOURCES
MyUsefulFile.txt
Read.me
Version.txt
)

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

顺便说一句:我避免使用 file( GLOB ...)。查看CMake documentation原因。

关于cmake - 如何在 QtCreator 中使用 CMAKE 列出自定义文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43319234/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com