Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to let some file to be visiable in QtCreator

I'm using cmake to configure my project. It seems QtCreator only show those files referred by add_executable, add_library and configure_file. Other files in project directory are not visiable in the Projects panel.

Although we can still visit those files by file->open, it make me feel bad that many important source files are not visiable in the Projects panel. So...

  • How does QtCreator decide whether to show a file?
  • Is there any cmake command that can make arbitrary file to be visiable in QtCreator?

=======================

Some additional info:

My project is a C++ library with PerlXS interface. XS code is preprocessed into C code by xsubpp, and this action is added into cmake project via add_custom_target. However, the XS file is not added into Porjects panel by QtCreator. Besides, a project can have non-source text files such as README, Changes, etc..

like image 480
jiandingzhe Avatar asked Feb 12 '23 05:02

jiandingzhe


1 Answers

I see no reason to put something specific with project, when you can switch to "File System" browser in QtCreator.

enter image description here

But anyway, the answer still the same. If you wish to see something in project - add it to add_executable, add_library.

For example

set(DATA_FILE ${PROJECT_SOURCE_DIR}/build/README.txt)
...
add_executable(${TARGET_NAME} ${SRC_FILES} ${GLB_HDR_FILES} ${DATA_FILE})

And now we can see README.txt in project

enter image description here

Same trick can be done for other files. Just add them to DATA_FILE variable.

like image 110
Sergei Nikulov Avatar answered Mar 02 '23 18:03

Sergei Nikulov