- Qt Creator Manual
- Add subprojects to projects
- Qt Creator Manual 13.0.2

How To

# Add subprojects to projects

You can link your application to Qt libraries and other libraries, such as system libraries or your own libraries. Further, your own libraries might link to other libraries. To compile your project and benefit from services such as code completion and syntax highlighting, add the libraries to your project. The process of adding a library to a project depends on the build system that you use.

## CMake projects

To add CMakeLists.txt files to any project, use the add_subdirectory command. The files can define complete projects that you include into the top-level project or any other CMake commands.

## qmake projects

When you create a new project and select qmake as the build system, you can add it to another project as a subproject in the Project Management dialog. However, the root project must specify that qmake uses the `subdirs` template to build the project.

To create a root project:

1. Select File > New Project > Other Project > Subdirs Project > Choose.
2. On the Summary page, select Finish & Add Subproject to create the root project and to add another project, such as a C++ library.

The wizard creates a project file (.pro) that defines a `subdirs` template and the subproject that you add as a value of the SUBDIRS variable. It also adds all the necessary files for the subproject.

### Add subprojects to the root project

To create more subprojects, right-click the project name in the Projects view to open the context menu, and select New Subproject. Follow the steps in the New Subproject wizard to create a subproject.

To add an existing project as a subproject, select Add Existing Projects in the context menu. In the file browser dialog, locate your subproject.

### Remove subprojects

To remove subprojects, right-click the project name in the Projects view, and select Remove Subproject in the context menu.

### Specify dependencies

To specify dependencies, use the Add Library wizard.

See also Creating Projects, Use project wizards, Add libraries to qmake projects, and Add libraries to CMake projects.

How To