aboutsummaryrefslogtreecommitdiffstats
path: root/doc/qtcreator/src/cmake/creator-projects-cmake.qdoc
blob: af8c13010502e4427dfba130096e3e57bb701020 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/****************************************************************************
**
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Creator documentation.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
**
****************************************************************************/

// **********************************************************************
// NOTE: the sections are not ordered by their logical order to avoid
// reshuffling the file each time the index order changes (i.e., often).
// Run the fixnavi.pl script to adjust the links to the index order.
// **********************************************************************

/*!
    \contentspage index.html
    \previouspage creator-project-other.html
    \page creator-project-cmake.html
    \nextpage creator-project-qbs.html

    \title Setting Up CMake

    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 and
    Android devices. You can also 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}.

    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 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.

    \section1 Adding CMake Tools

    \QC supports CMake version 3.0, or later. For best results you should use
    CMake version 3.7.2 with server-mode support, or later. Earlier versions
    provide less information to the code model, which will then fail to resolve
    includes and defines.

    For CMake version 3.14, or later, \QC supports the
    \l {https://cmake.org/cmake/help/latest/manual/cmake-file-api.7.html}
    {file-based API}.

    To specify paths to CMake executables:

    \list 1

        \li Select \uicontrol Tools > \uicontrol Options > \uicontrol Kits >
            \uicontrol CMake > \uicontrol Add.

            \image qtcreator-cmakeexecutable.png

        \li In the \uicontrol Name field, specify a name for the tool.

        \li In the \uicontrol Path field, specify the path to the CMake
            executable.

        \li In the \uicontrol {Help file} field, specify the path to the
            CMake help file (.qch) provided by and installed with CMake.

        \li Select the \uicontrol {Auto-create build directories} check box to
            automatically create build directories for CMake projects.

        \li Select \uicontrol Apply to save your changes.

    \endlist

    \note When the \uicontrol {Autorun CMake} check box is enabled, \QC
    automatically runs CMake when you make changes to \c {CMakeLists.txt} files.
    We recommend that you do not disable this check box, because that would
    eventually make \QC and the project disagree on what the project information
    is.

    Select the \uicontrol Kits tab to add the CMake tool to a build and run kit.
    The kit also specifies the CMake generator that is used for producing
    project files for \QC and the configuration variables that are used:

    \image qtcreator-kits.png

    For more information, see \l {Adding Kits}.

    \section1 Editing CMake Configuration Files

    To open a CMakeLists.txt file for editing, right-click it in the
    \uicontrol Projects view and select \uicontrol {Open With} >
    \uicontrol {CMake Editor}.

    You can also use the \c cmo filter in the \l {Searching with the Locator}
    {locator} to open the CMakeLists.txt file for the current run configuration
    in the editor. This is the same build target as when you select
    \uicontrol Build > \uicontrol {Build for Run Configuration}.

    The following features are supported:

    \list

        \li Pressing \key F2 when the cursor is on a filename to open the file

        \li Keyword completion

        \li Code completion

        \li Path completion

        \li Auto-indentation

        \li Matching parentheses and quotes

    \endlist

   \section1 Adding External Libraries to CMake Projects

    Through external libraries, \QC can support code completion and syntax
    highlighting as if they were 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
    in the \c {Modules} directory of your CMake installation.

    \note If you provide your own libraries, you also need to provide your own
    \c {FindXXX.cmake} file. For more information, see
    \l{https://gitlab.kitware.com/cmake/community/wikis/FAQ#writing-findxxxcmake-files}
    {Writing FindXXX.cmake files}.

    Syntax completion and highlighting work once your project successfully
    builds and links against the external library.

    \section1 Related Topics

    \list
        \li \l {Opening Projects}
        \li \l {Specifying Build Settings}
        \li \l {Specifying Run Settings}
        \li \l {Deploying CMake Projects to Embedded Linux Devices}
    \endlist
*/