Specify project contents
A project can have files that should be:
- Compiled or otherwise handled by the build
- Installed
- Not installed, but included in a source package created with
make dist
- Not installed, nor be part of a source package, but still be known to Qt Creator
The Projects view shows all files that you declare to be part of the project in the project files. It sorts the files into categories by file type (.cpp, .h, .qrc, and so on). To display additional files, edit the project file. Alternatively, you can see all the files in a project directory in the File System view.
Declaring files as a part of the project also makes them visible to the locator and project-wide search.
CMake Projects
When using CMake, you can specify additional files for a project by either adding them as sources or installing them.
In the CMakeLists.txt file, define the files as values of the target_sources command using the PRIVATE
property, for example.
You can prevent CMake from handling some files, such as a .cpp file that should not be compiled. Use the set_property command and the HEADER_FILE_ONLY property to specify such files. For example:
set_property(SOURCE "${files}" PROPERTY HEADER_FILE_ONLY ON)
Alternatively, to install the files, use the install command with the FILES
or DIRECTORY
property.
qmake Projects
Use the following variables in the .pro file:
SOURCES
andHEADERS
for files to compileINSTALLS
for files to installDISTFILES
for files to include in a source packageOTHER_FILES
for files to manage with Qt Creator without installing them or including them in source packages
For example, the following value includes text files in the source package:
DISTFILES += *.txt
See also Creating Projects, Use project wizards, and Projects.
© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.