QtCreator中的Cmake:源文件未显示在项目文件树视图中 [英] Cmake in QtCreator: Source file not displayed in project file tree view

查看:935
本文介绍了QtCreator中的Cmake:源文件未显示在项目文件树视图中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用CMake和QtCreator编写C代码。我通过在顶层打开CMakeLists.txt文件来打开我的项目。
我在QtCreator的项目文件树视图中看到了用于构建可执行文件或库的所有文件,如下所示:

I'm using CMake och QtCreator to write C code. I open my project by opening the CMakeLists.txt file on the top level. I see all the files in the project file tree view in QtCreator that are used to build executables or libraries like this:

add_library( my_lib file1.c )
add_executable( my_executable file2.c )

但是我有一个用于postgres的预编译文件,如下所示:

But I have one file that are used in precompilation for postgres like this:

set( MY_CMD "/usr/pgsql-9.3/bin/ecpg" )
set( MY_ARG "file3.pgc" )
add_custom_target( dummy_target ALL COMMAND ${MY_CMD} ${MY_ARG} WORKING_DIRECTORY ${MY_DIR} )

文件file3.pgc没有显示在项目文件树视图中。如何使QtCreator找到该文件?

The file file3.pgc is not displayed in the project file tree view. How can I make QtCreator find that file?

推荐答案

添加 SOURCES 选项到 add_custom_target http://www.cmake.org/cmake/help/v3.0/command/add_custom_target.html ):

add_custom_target(dummy_target ALL 
    COMMAND ${MY_CMD} ${MY_ARG} 
    WORKING_DIRECTORY ${MY_DIR} 
    SOURCES "${MY_DIR}/file3.pgc")

这篇关于QtCreator中的Cmake:源文件未显示在项目文件树视图中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆