forked from qt-creator/qt-creator
Doc: Describe CMake changes
- Divide the "Setting Up CMake" into several how-to topics. - Rename it as "CMake" and link to all the new topics. - Update related topics accordingly. Task-number: QTCREATORBUG-29361 Task-number: QTCREATORBUG-29392 Change-Id: Ib8f4a1951b5ffd7eaa25a4e5cf40e7bb252f9cf4 Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
2
dist/changelog/changes-12.0.0.md
vendored
2
dist/changelog/changes-12.0.0.md
vendored
@@ -242,6 +242,8 @@ Projects
|
||||
([QTCREATORBUG-29643](https://bugreports.qt.io/browse/QTCREATORBUG-29643))
|
||||
* Fixed unnecessary restrictions on the preset name
|
||||
|
||||
([Documentation](https://doc-snapshots.qt.io/qtcreator-12.0/creator-project-cmake.html))
|
||||
|
||||
### Python
|
||||
|
||||
* Added auto-detection of PySide from the installer
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.0 KiB |
@@ -6,6 +6,7 @@
|
||||
\previouspage creator-how-tos.html
|
||||
|
||||
\ingroup creator-how-to-debug
|
||||
\ingroup creator-how-to-build-with-cmake
|
||||
|
||||
\title Debug CMake project files
|
||||
|
||||
@@ -28,5 +29,5 @@
|
||||
\uicontrol Debug mode views.
|
||||
|
||||
\sa {Debugging},{Examining Data},{Debug Mode Views},{Setting Breakpoints},
|
||||
{Setting Up CMake}
|
||||
{CMake}
|
||||
*/
|
||||
|
||||
@@ -13,43 +13,84 @@
|
||||
|
||||
\ingroup creator-reference-build-systems
|
||||
|
||||
\title Setting Up CMake
|
||||
\title CMake
|
||||
|
||||
\brief CMake is an alternative to qmake for automating the generation of
|
||||
build systems.
|
||||
|
||||
CMake automates the configuration of build systems. It controls the software
|
||||
compilation process by using simple
|
||||
\l{https://cmake.org/}{CMake} automates the configuration of build systems.
|
||||
It controls the software compilation process by using simple
|
||||
configuration files, called \c {CMakeLists.txt} files. CMake generates
|
||||
native build configurations and workspaces that you can use in the compiler
|
||||
environment of your choice.
|
||||
|
||||
You can use CMake from \QC to build applications for the desktop, as well
|
||||
as mobile and embedded devices. You can also build single files to test
|
||||
your changes.
|
||||
as mobile and embedded devices. Or, build single files to test your changes.
|
||||
|
||||
\QC automatically detects the CMake executable specified in the \c PATH.
|
||||
You can add paths to other CMake executables and use them in different
|
||||
build and run \l{glossary-buildandrun-kit}{kits}.
|
||||
\section1 Supported CMake Versions
|
||||
|
||||
CMake documentation is installed in Qt help file format (.qch) when you
|
||||
install CMake. It is automatically registered by \QC, and you can view it
|
||||
in the Help mode.
|
||||
\QC requires CMake's \l{https://cmake.org/cmake/help/latest/manual/cmake-file-api.7.html}
|
||||
{file-based API}, and therefore you'll need CMake version 3.14, or later.
|
||||
|
||||
\QC automatically runs CMake to refresh project information when you edit
|
||||
a \c CMakeLists.txt configuration file in a project. Project information is
|
||||
also automatically refreshed when you build the project. To disable this
|
||||
behavior, select \preferences > \uicontrol CMake > \uicontrol General, and
|
||||
then deselect the \uicontrol {Autorun CMake} check box.
|
||||
For systems with older versions of CMake, only workarounds are available:
|
||||
|
||||
\list
|
||||
\li For CMake version 3.5 or later, generate a
|
||||
\l{CMake: CMAKE_EXPORT_COMPILE_COMMANDS}{compilation database} and
|
||||
open that in \QC, as described in \l{Using Compilation Databases}.
|
||||
\li Create an ad-hoc project file for a qmake build using
|
||||
\c{qmake -project} and \l{Open projects}{open} that in \QC.
|
||||
Typically, you cannot compile such projects without manual changes.
|
||||
\li Manually create an ad-hoc project file for a
|
||||
\l{Setting Up a Generic Project}{generic project} and
|
||||
open that in \QC.
|
||||
Typically, you cannot compile such projects without manual changes.
|
||||
\endlist
|
||||
|
||||
\sa {Build with CMake}{How To: Build with CMake}, {Open projects},
|
||||
{CMake Build Configuration}, {Debug CMake project files},
|
||||
{Specifying Build Settings}, {Specifying Run Settings},
|
||||
{Deploying to Remote Linux}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\page creator-how-to-view-cmake-project-contents.html
|
||||
\previouspage creator-how-tos.html
|
||||
|
||||
\ingroup creator-how-to-build-with-cmake
|
||||
|
||||
\title View CMake project contents
|
||||
|
||||
The \l Projects view visualizes the build system structure of the project as
|
||||
a tree and lists all files that are part of the project.
|
||||
\QC automatically runs CMake to refresh project information in the
|
||||
view when you edit a \c CMakeLists.txt configuration file
|
||||
in a project. Project information is also automatically refreshed when
|
||||
you build the project.
|
||||
|
||||
\image qtcreator-projects-view-edit.png {CMake project in Projects view}
|
||||
|
||||
If \QC cannot load the CMake project, the \l Projects view shows a
|
||||
To disable this
|
||||
behavior, select \preferences > \uicontrol CMake > \uicontrol General, and
|
||||
then deselect the \uicontrol {Autorun CMake} check box.
|
||||
|
||||
\image qtcreator-preferences-cmake-general.webp {General tab in CMake Preferences}
|
||||
|
||||
\section1 Re-configure CMake projects
|
||||
|
||||
If \QC cannot load the CMake project, the \uicontrol Projects view shows a
|
||||
\uicontrol {<File System>} project node to avoid scanning the file
|
||||
system and load the project faster. The node shows the same files
|
||||
as the \l {File System} view. Select \uicontrol Build >
|
||||
\uicontrol {Clear CMake Configuration}, and then select \uicontrol Build
|
||||
> \uicontrol {Run CMake} to reconfigure the project.
|
||||
as the \l {File System} view.
|
||||
|
||||
To re-configure the project:
|
||||
|
||||
\list 1
|
||||
\li Select \uicontrol Build > \uicontrol {Clear CMake Configuration}.
|
||||
\li Select \uicontrol Build > \uicontrol {Run CMake}.
|
||||
\endlist
|
||||
|
||||
\section1 Hide subfolder names in Projects view
|
||||
|
||||
The \uicontrol Projects view shows the names of the subfolders where the
|
||||
source files are located. To hide the subfolder names and arrange the files
|
||||
@@ -59,32 +100,47 @@
|
||||
box. The change takes effect after you select \uicontrol Build >
|
||||
\uicontrol {Run CMake}.
|
||||
|
||||
\section1 Adding CMake Tools
|
||||
\sa {CMake}, {Manage files in CMake projects}, {Open projects},
|
||||
{File System}, {Projects}
|
||||
*/
|
||||
|
||||
\QC requires CMake's \l{https://cmake.org/cmake/help/latest/manual/cmake-file-api.7.html}
|
||||
{file-based API}, and therefore you'll need CMake version 3.14, or later.
|
||||
/*!
|
||||
\page creator-how-to-read-cmake-documentation.html
|
||||
\previouspage creator-how-tos.html
|
||||
|
||||
\ingroup creator-how-to-build-with-cmake
|
||||
\ingroup creator-how-to-get-help
|
||||
|
||||
\title Read CMake documentation
|
||||
|
||||
CMake documentation is installed in Qt help file format (.qch) when you
|
||||
install CMake. It is automatically registered by \QC, and you can view it by:
|
||||
|
||||
For systems with older versions of CMake, only workarounds are available:
|
||||
\list
|
||||
|
||||
\li For CMake version 3.5 or later it is possible to generate a
|
||||
\l{https://cmake.org/cmake/help/latest/variable/CMAKE_EXPORT_COMPILE_COMMANDS.html}{compilation database}
|
||||
and open that in \QC, as described in \l{Using Compilation Databases}.
|
||||
|
||||
\li Create an ad-hoc project file for a qmake build using
|
||||
\c{qmake -project} and \l{Open projects}{open} that in \QC.
|
||||
Be aware that this is typically
|
||||
not compilable without further manual changes.
|
||||
|
||||
\li Manually create an ad-hoc project file for a
|
||||
\l{Setting Up a Generic Project}{generic project} and
|
||||
open that in \QC. Be aware this is typically
|
||||
not compilable without further manual changes.
|
||||
|
||||
\li Hovering the mouse over a function, variable, property, policy,
|
||||
environment variable, or CMake find or include module to show
|
||||
tooltips
|
||||
\li Selecting any of the above elements and pressing \key F1 to show
|
||||
its documentation
|
||||
\li Switching to the Help mode
|
||||
\endlist
|
||||
|
||||
\sa {CMake}, {Read Documentation}{How To: Read Documentation}
|
||||
*/
|
||||
|
||||
To view and specify settings for CMake:
|
||||
/*!
|
||||
\page creator-how-to-add-cmake-tools.html
|
||||
\previouspage creator-how-tos.html
|
||||
|
||||
\ingroup creator-how-to-build-with-cmake
|
||||
|
||||
\title Add CMake tools
|
||||
|
||||
\QC automatically detects the CMake executable that you specify in the
|
||||
\c PATH. You can add paths to other CMake executables and use them in
|
||||
different build and run \l{glossary-buildandrun-kit}{kits}.
|
||||
|
||||
To see the CMake installations that \QC automatically detects:
|
||||
|
||||
\list 1
|
||||
|
||||
@@ -101,20 +157,24 @@
|
||||
\li The \uicontrol {Help file} field displays the path to the
|
||||
CMake help file (.qch) that comes with CMake.
|
||||
|
||||
\li Select \uicontrol Apply to save your changes.
|
||||
|
||||
\endlist
|
||||
|
||||
\section2 Add or remove CMake tools
|
||||
|
||||
To add a path to a CMake executable that \QC does not detect automatically,
|
||||
and to specify settings for it, select \uicontrol Add. To make changes to
|
||||
automatically detected installations, select \uicontrol Clone.
|
||||
|
||||
To remove the selected CMake executable from the list, select
|
||||
\uicontrol Remove.
|
||||
|
||||
\section2 Set the default CMake tool
|
||||
|
||||
\QC uses the \e {default CMake} if it does not have enough information
|
||||
to choose the CMake to use. To set the selected CMake executable as the
|
||||
default, select \uicontrol {Make Default}.
|
||||
|
||||
To remove the selected CMake executable from the list, select
|
||||
\uicontrol Remove.
|
||||
\section2 Add CMake tools to kits
|
||||
|
||||
To add the CMake tool to a build and run kit, select \preferences >
|
||||
\uicontrol Kits.
|
||||
@@ -123,9 +183,16 @@
|
||||
|
||||
\image qtcreator-kits-cmake.png {Kits preferences}
|
||||
|
||||
For more information, see \l {Add kits} and \l {Kits}.
|
||||
\sa {CMake}, {Add kits}, {Kits}
|
||||
*/
|
||||
|
||||
\section1 Editing CMake Configuration Files
|
||||
/*!
|
||||
\page creator-how-to-edit-cmake-config-files.html
|
||||
\previouspage creator-how-tos.html
|
||||
|
||||
\ingroup creator-how-to-build-with-cmake
|
||||
|
||||
\title Edit CMake configuration files
|
||||
|
||||
To open a CMakeLists.txt file for editing, right-click it in the
|
||||
\uicontrol Projects view and select \uicontrol {Open With} >
|
||||
@@ -140,11 +207,22 @@
|
||||
|
||||
\list
|
||||
|
||||
\li Pressing \key F2 when the cursor is on a filename to open the file
|
||||
\li Pressing \key F2 when the cursor is on a:
|
||||
\list
|
||||
\li Filename - to open the file
|
||||
\li CMake function, macro, option, target, CMake's Find or
|
||||
Include module, local variable created by \c set or \c list,
|
||||
or package - to go to that item
|
||||
\endlist
|
||||
|
||||
\li Keyword completion
|
||||
|
||||
\li Code completion
|
||||
\li Code completion for local functions and variables, cache variables,
|
||||
\c ENV, targets, packages, and variables that \c find_package adds
|
||||
|
||||
\li Pre-defined code snippets for setting CMake print properties and
|
||||
variables, as well as creating Qt console and GUI applications and
|
||||
sample Find modules
|
||||
|
||||
\li Path completion
|
||||
|
||||
@@ -156,13 +234,48 @@
|
||||
|
||||
Warnings and errors are displayed in \l {Issues}.
|
||||
|
||||
\section1 Formatting CMake Files
|
||||
\sa {CMake}, {Add libraries to CMake projects}, {Complete CMake code},
|
||||
{Completing Code Snippets}, {Format CMake files}
|
||||
*/
|
||||
|
||||
You can use the \c {cmake-format} tool to format any text in CMake files that
|
||||
/*!
|
||||
\page creator-how-to-complete-cmake-code.html
|
||||
\previouspage creator-how-tos.html
|
||||
|
||||
\ingroup creator-how-to-build-with-cmake
|
||||
|
||||
\title Complete CMake code
|
||||
|
||||
\QC uses \l{Generic Highlighting}{generic highlighting} to provide
|
||||
code completion specific arguments for the CMake commands. For
|
||||
example, only source file properties are suggested for the
|
||||
\l {CMake: set_source_files_properties command}, not the test or
|
||||
target properties.
|
||||
|
||||
The following CMake-specific trigger tokens are supported:
|
||||
|
||||
\list
|
||||
\li \c{$} for variables
|
||||
\li \c{$<} for generator expressions
|
||||
\li \c{$ENV} for environment variables
|
||||
\endlist
|
||||
|
||||
\sa {CMake}, {Completing Code}, {Completing Code Snippets},
|
||||
{Edit CMake configuration files}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\page creator-how-to-format-cmake-files.html
|
||||
\previouspage creator-how-tos.html
|
||||
|
||||
\ingroup creator-how-to-build-with-cmake
|
||||
|
||||
\title Format CMake files
|
||||
|
||||
You can use the \l {cmake-format} tool and local \c .cmake-format, \c.py, or
|
||||
\c .json configuration files to format any text in CMake files that
|
||||
you do not guard with a pair of fences. You must install the tool and tell
|
||||
\QC where you installed it. For more information about the tool and how to
|
||||
install it, see \l{https://cmake-format.readthedocs.io/en/latest/index.html}
|
||||
{cmake language tools}.
|
||||
\QC where you installed it.
|
||||
|
||||
To automatically format CMake files upon file save:
|
||||
|
||||
@@ -171,7 +284,7 @@
|
||||
\image qtcreator-preferences-cmake-formatter.webp {Formatter tab in CMake Preferences}
|
||||
\li In \uicontrol {CMakeFormat command}, enter the path to
|
||||
\c {cmake-format.exe}.
|
||||
\li Select \uicontrol {Enable auto format on file save} to automatically
|
||||
\li Select \uicontrol {Automatic formatting on file save} to automatically
|
||||
format CMake files when you save them.
|
||||
\li In \uicontrol {Restrict to MIME types}, add the \l{Editing MIME Types}
|
||||
{MIME types} of the files to format, separated by semicolons. The
|
||||
@@ -182,37 +295,86 @@
|
||||
current project.
|
||||
\endlist
|
||||
|
||||
\section1 Managing Files
|
||||
\sa {CMake},{Complete CMake code}, {Edit CMake configuration files},
|
||||
{Editing MIME Types}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\page creator-how-to-manage-files-in-cmake-projects.html
|
||||
\previouspage creator-how-tos.html
|
||||
|
||||
\ingroup creator-how-to-build-with-cmake
|
||||
|
||||
\title Manage files in CMake projects
|
||||
|
||||
When you use project wizard templates to \l{Create files}{add files} to
|
||||
a project, \QC automatically adds them to the \c {qt_add_executable()},
|
||||
\c {add_executable()}, or \c {qt_add_library()} function in the
|
||||
CMakeLists.txt file.
|
||||
a project, \QC automatically adds them to the \l {qt_add_executable},
|
||||
\l{CMake: add_executable command}{add_executable}, or \l {qt_add_library}
|
||||
function in the CMakeLists.txt file.
|
||||
|
||||
If you use custom API, \QC uses \c {target_sources()} to add the files.
|
||||
If you use custom API, \QC uses the \l{CMake: target_sources command}
|
||||
{target_sources} function to add the files.
|
||||
|
||||
For Qt Quick projects, the files are added to the \c {qt_add_qml_module()}
|
||||
For Qt Quick projects, the files are added to the \l {qt_add_qml_module}
|
||||
function, prefixed with the \c QML_FILES, \c SOURCES, or \c RESOURCES
|
||||
function argument.
|
||||
|
||||
When you rename or remove files in the \l {Projects} or \l {File System}
|
||||
view, \QC renames them in the CMakeLists.txt file or removes them from it.
|
||||
|
||||
\section1 Adding External Libraries to CMake Projects
|
||||
\sa {CMake}, {Add libraries to CMake projects}, {Create files},
|
||||
{Edit CMake configuration files}, {View CMake project contents},
|
||||
{File System}, {Projects}
|
||||
*/
|
||||
|
||||
/*!
|
||||
\page creator-how-to-add-external-libraries-to-cmake-projects.html
|
||||
\previouspage creator-how-tos.html
|
||||
|
||||
\ingroup creator-how-to-projects
|
||||
\ingroup creator-how-to-build-with-cmake
|
||||
|
||||
\title Add libraries to CMake projects
|
||||
|
||||
\include creator-projects-libraries.qdoc libraries
|
||||
|
||||
\section1 Add your own libraries
|
||||
|
||||
Use the \l qt_add_library command to create a library and link against it in
|
||||
the CMakeLists.txt file, as instructed in \l{Structuring projects}.
|
||||
|
||||
Specify whether the library is statically or dynamically linked.
|
||||
For a statically linked internal library, add the
|
||||
\l{CMake: target_link_libraries command} to the CMakeLists.txt
|
||||
project file to specify dependencies.
|
||||
|
||||
\section1 Add external libraries
|
||||
|
||||
Through external libraries, \QC can support code completion and syntax
|
||||
highlighting as if they were part of the current project or the Qt library.
|
||||
highlighting as if the code were a part of the current project or the
|
||||
Qt library.
|
||||
|
||||
\QC detects the external libraries using the \c {find_package()}
|
||||
macro. Some libraries come with the CMake installation. You can find those
|
||||
\QC detects the external libraries using the \l{CMake: find_package command}
|
||||
command. Some libraries come with the CMake installation. You can find those
|
||||
in the \c {Modules} directory of your CMake installation.
|
||||
For more information, see
|
||||
\l{https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html}
|
||||
{cmake-packages(7)}.
|
||||
For more information, see \l{CMake: cmake-packages(7)}.
|
||||
|
||||
Syntax completion and highlighting work once your project successfully
|
||||
builds and links against the external library.
|
||||
\section1 Use local CMake Find packages
|
||||
|
||||
\sa {Open projects}, {CMake Build Configuration}, {Debug CMake project files},
|
||||
{Specifying Run Settings}, {Deploying to Remote Linux}
|
||||
For CMake projects that have external dependencies, use
|
||||
\l{CMake: Find Modules}{Find<package>.cmake} modules that
|
||||
expose imported targets. You can use the pre-defined \c sample_find_module
|
||||
\l{Completing Code Snippets}{code snippet} to add sample commands
|
||||
to a \c .cmake file. You can then change the commands as necessary.
|
||||
|
||||
Place Find modules in the \c ${CMAKE_CURRENT_SOURCE_DIR}/cmake directory, and
|
||||
append the directory name to the CMAKE_MODULE_PATH list variable.
|
||||
For example:
|
||||
|
||||
\code
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
\endcode
|
||||
|
||||
\sa {CMake}, {Edit CMake configuration files}, {Complete CMake code},
|
||||
{Completing Code Snippets}
|
||||
*/
|
||||
|
||||
@@ -101,6 +101,18 @@
|
||||
\externalpage https://cmake.org/cmake/help/latest/manual/cmake-variables.7.html
|
||||
\title CMake: cmake-variables(7)
|
||||
*/
|
||||
/*!
|
||||
\externalpage https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html
|
||||
\title CMake: cmake-packages(7)
|
||||
*/
|
||||
/*!
|
||||
\externalpage https://cmake.org/cmake/help/latest/command/add_executable.html
|
||||
\title CMake: add_executable command
|
||||
*/
|
||||
/*!
|
||||
\externalpage https://cmake.org/cmake/help/latest/command/find_package.html
|
||||
\title CMake: find_package command
|
||||
*/
|
||||
/*!
|
||||
\externalpage https://cmake.org/cmake/help/latest/command/install.html
|
||||
\title CMake: install command
|
||||
@@ -109,6 +121,10 @@
|
||||
\externalpage https://cmake.org/cmake/help/latest/command/set_property.html
|
||||
\title CMake: set_property command
|
||||
*/
|
||||
/*!
|
||||
\externalpage https://cmake.org/cmake/help/latest/command/set_source_files_properties.html
|
||||
\title CMake: set_source_files_properties command
|
||||
*/
|
||||
/*!
|
||||
\externalpage https://cmake.org/cmake/help/latest/command/target_compile_definitions.html
|
||||
\title CMake: target_compile_definitions command
|
||||
@@ -121,6 +137,10 @@
|
||||
\externalpage https://cmake.org/cmake/help/latest/command/target_sources.html
|
||||
\title CMake: target_sources command
|
||||
*/
|
||||
/*!
|
||||
\externalpage https://cmake.org/cmake/help/latest/manual/cmake-developer.7.html#find-modules
|
||||
\title CMake: Find Modules
|
||||
*/
|
||||
/*!
|
||||
\externalpage https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_DEPLOYMENT_TARGET.html
|
||||
\title CMake: CMAKE_OSX_DEPLOYMENT_TARGET
|
||||
@@ -129,6 +149,14 @@
|
||||
\externalpage https://cmake.org/cmake/help/latest/prop_sf/HEADER_FILE_ONLY.html
|
||||
\title CMake: HEADER_FILE_ONLY
|
||||
*/
|
||||
/*!
|
||||
\externalpage https://cmake.org/cmake/help/latest/variable/CMAKE_EXPORT_COMPILE_COMMANDS.html
|
||||
\title CMake: CMAKE_EXPORT_COMPILE_COMMANDS
|
||||
*/
|
||||
/*!
|
||||
\externalpage https://cmake-format.readthedocs.io/en/latest/cmake-format.html
|
||||
\title cmake-format
|
||||
*/
|
||||
/*!
|
||||
\externalpage https://microsoft.github.io/language-server-protocol/
|
||||
\title Language Server Protocol
|
||||
|
||||
@@ -371,7 +371,8 @@
|
||||
\li Follow symbol under cursor
|
||||
|
||||
Works with namespaces, classes, functions, variables, include
|
||||
statements, and macros. Also, opens URLs in the default browser
|
||||
statements, and macros, as well as CMake functions, macros,
|
||||
targets, and packages. Also, opens URLs in the default browser
|
||||
\if defined(qtcreator)
|
||||
and Qt resource files (.qrc) in the \l{Resource Files}
|
||||
{resource editor}
|
||||
|
||||
@@ -20,6 +20,14 @@
|
||||
|
||||
\generatelist creator-how-to-build
|
||||
|
||||
\section2 Build with CMake
|
||||
|
||||
\generatelist creator-how-to-build-with-cmake
|
||||
|
||||
\section2 Build with qmake
|
||||
|
||||
\generatelist creator-how-to-build-with-qmake
|
||||
|
||||
\section1 Debug
|
||||
|
||||
\generatelist creator-how-to-debug
|
||||
@@ -52,7 +60,7 @@
|
||||
|
||||
\generatelist creator-how-to-projects-configure
|
||||
|
||||
\section1 Read Qt Documentation
|
||||
\section1 Read Documentation
|
||||
|
||||
\generatelist creator-how-to-get-help
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
\li \l {Build with CMake}{CMake} is a cross-platform system for build
|
||||
automation that helps simplify the build process for development
|
||||
projects across different platforms. It automates the generation of
|
||||
build configurations. For more information, see \l {Setting Up CMake}.
|
||||
build configurations. For more information, see \l {CMake}.
|
||||
\li \l{qmake Manual}{qmake} is an alternative to CMake for automating the
|
||||
generation of build configurations. Qt installers install and
|
||||
configure qmake. To use one of the other supported build systems,
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
|
||||
\image qtcreator-preferences-cmake-tools.webp "Tools tab in CMake Preferences"
|
||||
|
||||
For more information, see \l {Setting Up CMake}.
|
||||
For more information, see \l {CMake}.
|
||||
|
||||
\section1 Building with qmake
|
||||
|
||||
|
||||
@@ -316,5 +316,5 @@
|
||||
To specify dependencies, use the \uicontrol{Add Library} wizard.
|
||||
|
||||
\sa {Creating Projects}, {Use project wizards},
|
||||
{Add libraries to projects}
|
||||
{Add libraries to qmake projects}, {Add libraries to CMake projects}
|
||||
*/
|
||||
|
||||
@@ -188,7 +188,7 @@
|
||||
\li \uicontrol {CMake Tool}
|
||||
\li CMake executable to use for building the project. Select
|
||||
\uicontrol Manage to add installed CMake executables to
|
||||
the list. For more information, see \l{Adding CMake Tools}.
|
||||
the list. For more information, see \l{Add CMake Tools}.
|
||||
\row
|
||||
\li \uicontrol {CMake generator}
|
||||
\li Select \uicontrol Change to edit the CMake Generator to use for
|
||||
@@ -212,6 +212,7 @@
|
||||
\uicontrol Manage to add installed Ninja tools to the list.
|
||||
\endtable
|
||||
|
||||
\sa {Activate kits for a project}, {Open projects}, {Add compilers},
|
||||
{Add debuggers}, {Add kits}, {Add Qt versions}, {Edit Qbs profiles}
|
||||
\sa {Activate kits for a project}, {Open projects}, {Add CMake Tools},
|
||||
{Add compilers}, {Add debuggers}, {Add kits}, {Add Qt versions},
|
||||
{Edit Qbs profiles}
|
||||
*/
|
||||
|
||||
@@ -12,9 +12,11 @@
|
||||
\previouspage creator-how-tos.html
|
||||
|
||||
\ingroup creator-how-to-projects-create
|
||||
\ingroup creator-how-to-build-with-qmake
|
||||
|
||||
\title Add libraries to projects
|
||||
\title Add libraries to qmake projects
|
||||
|
||||
//! [libraries}
|
||||
In addition to Qt libraries, you can add other libraries to your projects.
|
||||
The process depends on the type and location of the library:
|
||||
|
||||
@@ -24,17 +26,13 @@
|
||||
\li A 3rd party library
|
||||
\endlist
|
||||
|
||||
\QC supports code completion and syntax highlighting for the added
|
||||
libraries once your project successfully builds and links to them.
|
||||
//! [libraries}
|
||||
|
||||
The library can be located either in the build tree of the current project or
|
||||
in another build tree.
|
||||
|
||||
\section1 CMake projects
|
||||
|
||||
If you use CMake to build the project, use the \l qt_add_library command to
|
||||
create a library and link against it in the CMakeLists.txt file, as
|
||||
instructed in \l{Structuring projects}.
|
||||
|
||||
\section1 qmake projects
|
||||
|
||||
To add libraries to projects that you build with qmake:
|
||||
|
||||
\list 1
|
||||
@@ -46,7 +44,7 @@
|
||||
The settings depend on the library type.
|
||||
\endlist
|
||||
|
||||
\section1 Library settings
|
||||
\section1 Library location
|
||||
|
||||
Because system libraries do not typically change and are often found by
|
||||
default, you do not need to specify the path to the library or to its
|
||||
@@ -58,13 +56,18 @@
|
||||
but you need to check it and modify it if necessary. \QC automatically
|
||||
adds the include path for an internal library.
|
||||
|
||||
\section1 Target platform
|
||||
|
||||
For all libraries, select the target platforms for the application, library,
|
||||
or plugin.
|
||||
|
||||
\section1 Linking
|
||||
|
||||
Specify whether the library is statically or dynamically linked. For a
|
||||
statically linked internal library, \QC adds dependencies
|
||||
(\l{CMake: target_link_libraries command}{target_link_libraries} when using
|
||||
CMake or \l PRE_TARGETDEPS when using qmake) in the project file.
|
||||
statically linked internal library, \QC adds dependencies as the value of
|
||||
the \l PRE_TARGETDEPS qmake variable in the project file (.pro).
|
||||
|
||||
\section1 Development platform
|
||||
|
||||
Depending on the development platform, \QC might detect some options
|
||||
automatically. For example, on \macos, it detects the library type
|
||||
@@ -85,14 +88,12 @@
|
||||
If the library name ends in \e d, deselect the \uicontrol {Remove "d" suffix
|
||||
for release version} option.
|
||||
|
||||
\QC supports code completion and syntax highlighting for the added
|
||||
libraries once your project successfully builds and links to them.
|
||||
|
||||
For more information about the project file settings, see
|
||||
\l{Declaring Other Libraries}.
|
||||
\l{Declaring Other Libraries}{qmake Manual: Declaring Other Libraries}.
|
||||
|
||||
\sa {Adding an Internal Library to a qmake Project},
|
||||
{Add subprojects to projects}, {Use project wizards}, {Creating Projects}
|
||||
\sa {Adding an Internal Library to a qmake Project}{Tutorial: Adding an Internal Library to a qmake Project},
|
||||
{Add subprojects to projects}, {Add libraries to CMake projects},
|
||||
{Use project wizards}, {Creating Projects}
|
||||
*/
|
||||
|
||||
/*!
|
||||
@@ -198,6 +199,7 @@
|
||||
else:unix: PRE_TARGETDEPS += $$OUT_PWD/../../../projects/mylib/libmylib.a
|
||||
\endcode
|
||||
|
||||
\sa {Add libraries to projects}, {Add subprojects to projects},
|
||||
{Select the build system}, {Use project wizards}, {Creating Projects}
|
||||
\sa {Add libraries to qmake projects}, {Add libraries to CMake projects},
|
||||
{Add subprojects to projects}, {Select the build system},
|
||||
{Use project wizards}, {Creating Projects}
|
||||
*/
|
||||
|
||||
@@ -180,6 +180,10 @@
|
||||
\list
|
||||
\li Build and Run
|
||||
\generatelist creator-how-to-build
|
||||
\li Build with CMake
|
||||
\generatelist creator-how-to-build-with-cmake
|
||||
\li Build with qmake
|
||||
\generatelist creator-how-to-build-with-qmake
|
||||
\li Debug
|
||||
\generatelist creator-how-to-debug
|
||||
\li Design UIs
|
||||
@@ -198,7 +202,7 @@
|
||||
\li Configure Projects
|
||||
\generatelist creator-how-to-projects-configure
|
||||
\endlist
|
||||
\li Read Qt Documentation
|
||||
\li Read Documentation
|
||||
\generatelist creator-how-to-get-help
|
||||
\li Use \QC
|
||||
\generatelist creator-how-to-use
|
||||
|
||||
@@ -97,7 +97,7 @@
|
||||
\li \l{Edit Code}
|
||||
\li \l{Manage Projects}
|
||||
\li \l{Build and Run}
|
||||
\li \l{Read Qt Documentation}
|
||||
\li \l{Read Documentation}
|
||||
\li \l{Use \QC}
|
||||
\li \l{Use the UI}
|
||||
\endlist
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
\QDS, select \uicontrol {Create a project that you can open in \QDS}.
|
||||
|
||||
\li In the \uicontrol {Build system} field, select the build system to
|
||||
use for building and running the project: \l {Setting Up CMake}
|
||||
use for building and running the project: \l {CMake}
|
||||
{CMake} or \l {Setting Up Qbs}{Qbs}.
|
||||
|
||||
\li Select \uicontrol Next to open the
|
||||
|
||||
@@ -110,5 +110,7 @@
|
||||
To stop the synchronization with the file currently open in the
|
||||
editor, deselect \inlineimage icons/linkicon.png
|
||||
(\uicontrol {Synchronize with Editor}).
|
||||
|
||||
\sa {View CMake project contents}, {Projects}
|
||||
\endif
|
||||
*/
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
{generic projects}.
|
||||
\li Add existing files and directories.
|
||||
\li Add libraries. For more information, see
|
||||
\l{Add libraries to projects}.
|
||||
\l{Add libraries to qmake projects}.
|
||||
\li Add and remove subprojects.
|
||||
\li Find unused functions.
|
||||
\endif
|
||||
@@ -151,5 +151,7 @@
|
||||
from the version control system in brackets after the project name.
|
||||
\QC currently implements this for Git (the view displays the branch name
|
||||
or a tag) and ClearCase (the view displays the branch name).
|
||||
|
||||
\sa {View CMake project contents}, {File System}
|
||||
\endif
|
||||
*/
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
|
||||
\image qtcreator-new-project-build-system-qt-gui.png {Define Build System dialog}
|
||||
|
||||
\li In the \uicontrol {Build system} field, select \l {Setting Up CMake}
|
||||
\li In the \uicontrol {Build system} field, select \l {CMake}
|
||||
{CMake} as the build system to use for building the project.
|
||||
|
||||
\li Select \uicontrol Next or \uicontrol Continue to open the
|
||||
|
||||
Reference in New Issue
Block a user