Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
CMake
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mattias Ellert
CMake
Commits
4bdc1c0a
Commit
4bdc1c0a
authored
4 years ago
by
Kyle Edwards
Browse files
Options
Downloads
Patches
Plain Diff
Help: Update user interaction guide with presets info
parent
8c4c658a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Help/guide/user-interaction/index.rst
+76
-0
76 additions, 0 deletions
Help/guide/user-interaction/index.rst
with
76 additions
and
0 deletions
Help/guide/user-interaction/index.rst
+
76
−
0
View file @
4bdc1c0a
...
...
@@ -142,6 +142,9 @@ methods are:
``DEVELOPER_DIR`` environment variable when running
CMake and the build tool.
For convenience, :manual:`cmake-gui(1)` provides an
environment variable editor.
Command line ``-G`` option
--------------------------
...
...
@@ -408,6 +411,79 @@ the configuration of the build, such as whether tests
and examples are built, whether to build with exceptions
enabled etc.
Presets
=======
CMake understands a file, ``CMakePresets.json``, and its
user-specific counterpart, ``CMakeUserPresets.json``, for
saving presets for commonly-used configure settings. These
presets can set the build directory, generator, cache
variables, environment variables, and other command-line
options. All of these options can be overridden by the
user. The full details of the ``CMakePresets.json`` format
are listed in the :manual:`cmake(1)` manual.
Using presets on the command-line
---------------------------------
When using the :manual:`cmake(1)` command line tool, a
preset can be invoked by using the ``--preset`` option. If
``--preset`` is specified, the generator and build
directory are not required, but can be specified to
override them. For example, if you have the following
``CMakePresets.json`` file:
.. code-block:: json
{
"version": 1,
"configurePresets": [
{
"name": "ninja-release",
"binaryDir": "${sourceDir}/build/${presetName}",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
}
]
}
and you run the following:
.. code-block:: console
cmake -S /path/to/source --preset=ninja-release
This will generate a build directory in
``/path/to/source/build/ninja-release`` with the
:generator:`Ninja` generator, and with
:variable:`CMAKE_BUILD_TYPE` set to ``Release``.
If you want to see the list of available presets, you can
run:
.. code-block:: console
cmake -S /path/to/source --list-presets
This will list the presets available in
``/path/to/source/CMakePresets.json`` and
``/path/to/source/CMakeUsersPresets.json`` without
generating a build tree.
Using presets in cmake-gui
--------------------------
If a project has presets available, either through
``CMakePresets.json`` or ``CMakeUserPresets.json``, the
list of presets will appear in a drop-down menu in
:manual:`cmake-gui(1)` between the source directory and
the binary directory. Choosing a preset sets the binary
directory, generator, environment variables, and cache
variables, but all of these options can be overridden after
a preset is selected.
Invoking the Buildsystem
========================
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment