Selecting a configure preset applies on the worker thread, but Configure
and Generate stayed enabled and could snapshot the stale cache model
first. Tokenize preset application, disable the dependent actions until
the completion lands, and accept only the latest request.
Fixes: #28085
The GUI ignored a preset's installDir, so CMAKE_INSTALL_PREFIX fell back
to the platform default instead of the value the command line uses. This
fixes that by reading installDir in QCMake::properties(), and while we're
there, it applies toolchainFile after the cacheVariables loop so both
override a same-named entry.
Fixes: #27804
System file dialogs might return directory path with trailing slash,
which is a problem for source path, because then the ${sourceDirName} in
presets evaluates to empty string. Resolve that by stripping the
trailing slashes from source and binary dirs.
QCMake::setPreset() bound a reference to the selected preset's expanded
data inside CMakePresetsGraph.ConfigurePresets and then called
setBinaryDirectory(). When the selected preset's build directory holds a
cache whose CMAKE_HOME_DIRECTORY differs from the current source
directory (e.g. because the source path is reached through a symbolic
link, since browsing keeps the link unresolved while the cache stores the
real path), setBinaryDirectory() loads that cache and re-sets the source
directory. That re-reads the presets graph via loadPresets(), which
calls ClearPresets() and destroys the map entry, leaving the reference
dangling. Subsequent access crashed with a use-after-free.
Copy the expanded preset instead of holding a reference into the graph so
it stays valid across setBinaryDirectory().
Fixes: #27927
Allow CMake, CTest, and CPack to read presets from a path given by
command-line argument instead of always requiring `CMakePresets.json`
or `CMakeUserPresets.json` in the source tree. This makes the presets
feature more extensible to cases in which the user doesn't have access
to the presets defined in the source tree (e.g., if the source tree is
not writable).
For now, there is no equivalent implementation of such an option in the
`cmake-gui`, nor for the recent presets functionality implemented in
`ctest_configure` and `ctest_build`.
Fixes: #27329
References to `CMake[User]Presets.json` should correspond to behavior
pertaining to those files in particular, while references to presets
files generally should be disambiguated from that.
Re-spell "preset file" to "presets file" where applicable.
Make a few references to `cmake-presets(7)` more consistent.
Issue: #27329
Replace the old (and poorly designed) mechanisms for altering warnings
in cmake-gui with a new warning tree that adaptively handles all
diagnostic categories that are defined.
Add an additional state to the cmake instance to track diagnostics. Use
this to initialize any new/reset states we create so that other contexts
will inherit the diagnostic state from presets / command-line options.
Modify the front-end to map presets and -W command-line options to
manipulation of this new diagnostic state. Remove old members for
storing diagnostic state. Rework how diagnostic state is persisted.
Deprecate old, non-standard spellings for manipulating diagnostics.
Deprecate old 'dev' spelling for CMD_AUTHOR.
Note that this is a work in progress. Messaging has not yet been
updated, so the new state is not yet being used to control diagnostics,
and some of the logic to update the old state has been stripped (and
will eventually be removed entirely). Backward compatibility support for
the deprecated CMAKE_{WARN,ERROR}_DEPRECATED variables is only partially
implemented. The GUI's interface for manipulating warnings is partially
broken and needs to be overhauled. These tasks are being done in
separate commits in order to minimize review burden and keep the changes
per commit / per merge request more manageable.
Modify diagnostics to track which preset schema version corresponds to
the introduction of each diagnostic. Modify how we parse presets to use
the set of diagnostics to generate bindings, and to store diagnostics as
maps rather than as fixed members. Enforce that only diagnostics known
to the specified preset version are present.
This is a first and necessary step toward moving CMake's internals over
to flexible categories rather than each category having its own bespoke
variables and member functions.
Note that the presets documentation currently contains some broken
links, as it is anticipating further documentation updates that will
happen in a future commit.
Since commit 1fef953655 (Utilities/Release: Update to Qt 6.10.1 on
Windows builds, 2025-12-08) our official binaries on Windows now honor
dark mode. However, this dialog became unreadable, seemingly due to
QTBUG-123853. Setting the wizard style to itself seems to work around
the problem.
Fixes: #27587
Qt-Issue: https://qt-project.atlassian.net/browse/QTBUG-123853
Suggested-by: Matthew Woehlke <matthew.woehlke@kitware.com>
Revert commit 27a73f1613 (cmake-gui: Add build option to use Qt5 windows
plugin statically, 2017-11-13, v3.10.0~3^2~1). Our builds on Windows
all use Qt 6 now.
QStandardItemModel::beginResetModel() and
QStandardItemModel::endResetModel() calls cannot be nested, and Qt will
produce warnings at runtime if such nesting is detected.
The nesting happened in two places:
1. QCMakeCacheModel::setViewType calls QCMakeCacheModel::setProperties.
Both called beginResetModel.
2. QCMakeCacheModel::setProperties calls QStandardItemModel::clear(),
which also calls beginResetModel.
The fix for 1 is to remove the {begin|end}ResetModel calls from
setViewType. The setProperties calls take care of the
{begin|end}ResetModel calls.
The fix for 2 is to replace the clear() call with a call that removes
all data rows.
Issue: #27376
The explicit initialization with empty paths from commit 57bdc1a2f7
(cmState: Compute and store directory components., 2015-05-04,
v3.3.0-rc1~61^2~4) has not been needed since commit 6afd35b98a (cmState:
remove unused code, 2016-06-16, v3.7.0-rc1~90^2).
In commit cbf0d3da52 (cmake-gui: Port away from deprecated API in Qt >=
6.7, 2025-02-21, v4.1.0-rc1~755^2~4) we assumed that `Qt::CheckState` is
implemented as an `int`. Spell out the type explicitly for the Qt 6.7+
callback signatures.
Move logic from commit c85524a94a (Ensure stdin, stdout, and stderr pipes
are always open, 2019-05-02, v3.15.0-rc1~171^2) and commit 96010cc968
(Ensure stdin, stdout, stderr FILE streams are open on Windows, 2024-01-24,
v3.29.0-rc1~65^2) to a dedicated source. Expose it through an `Init` class
constructor to make it optionally available during static initialization.
Issue: #26924
e9c494005c cmake-gui: Fix regression that prints an incidental error on fresh build trees
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10429
Since commit a872844908 (cmake-gui: Handle relative paths in the build
directory text input, 2024-04-24, v3.30.0-rc1~5^2), `cmake-gui` gave an
incidental error message even when a valid build directory was being
passed. Fix this by checking for a non-empty path before using it.
Fixes: #26744
Previously the presets handler in the GUI was on a timer. Because of
this, error messages got suppressed after the first one (even if the
error message is different from the one originally suppressed).
Add a "reload presets" button which forces the preset to reload, and
always provides an error message if the reload failed.
Fixes: #26707
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`, now with "east const" enforcement.
Use `clang-format` version 18.
* If you reached this commit for a line in `git blame`, re-run the blame
operation starting at the parent of this commit to see older history
for the content.
* See the parent commit for instructions to rebase a change across this
style transition commit.
Issue: #26123
Since commit 249a9bb44d (cmake-gui: use BundleUtilities in place of
custom script., 2010-10-14, v2.8.4~299^2) our install scripts include
the `BundleUtilities` module from our own source, rather than from the
`cmake` that's running at install time. We've now long required a
`cmake` version high enough to have the `BundleUtilities` we need.
Avoid including a `BundleUtilities` that may be newer than the running
`cmake` understands.
Our development workflow tooling prevents trailing blank lines
from being added, but some such lines remain from before that
was enforced. Remove them to make it easier to rename files
without triggering enforcement.