11 Commits
Author SHA1 Message Date
Aiden Woodruff fc3c71d11f cmake: Add cached environment id that triggers reconfigure when changed
The opaque `CMAKE_SYSTEM_ENVIRONMENT_ID` variable is cached during the
first invocation of `cmake` and is a user-defined hint about the state
of the environment. When the value changes, `cmake` either does nothing,
emits a warning (by default), or refreshes the cache as if by `--fresh`.
The action is controlled by the `CMAKE_SYSTEM_ENVIRONMENT_ACTION`
environment variable (which is not cached).

Implements: #28025
2026-08-24 15:06:35 -04:00
Aiden Woodruff f5837208f5 CMAKE_TOOLCHAIN_FILE: Fix Windows saved input toolchain file syntax error
The value of _CMAKE_INPUT_TOOLCHAIN_FILE can contain backslashes when
Windows path separators are used. This commit ensures regression tests
check such cases and saves the value with a bracket argument to avoid
causing a syntax error due to the backslashes.

Fixes: #28024
2026-08-07 13:04:14 -04:00
Aiden Woodruff 996fc21020 Tests: Enable toolchain parts of RunCMake.CompilerChange on Windows
A regression was missed partially due to this suite's condition. The
compiler specific pieces still need this condition because a shell
script needs to pretend to be a compiler, but the toolchain parts are
platform agnostic.

Issue: #28024
2026-08-07 13:03:49 -04:00
Aiden Woodruff 7bc37a0561 CMAKE_TOOLCHAIN_FILE: Avoid excess reconfigures from relative paths
Save original input value of CMAKE_TOOLCHAIN_FILE also before
normalization or relative searching to avoid reconfiguring because the
full path doesn't match the input. Tests correct behavior avoiding
reconfigures and ensuring reconfigure on toolchain change from preset.

Fixes: #24942
2026-07-22 11:53:05 -04:00
Aiden Woodruff ca3d1007f0 Tests: Simplify RunCMake.CompilerChange
The test suite can be simplified now that command line arguments are
restored after resetting the cache due to a compiler change. Previously
the test case name had to be set in the environment and now that is not
required.
2026-07-03 10:20:20 -04:00
Aiden Woodruff ee6bfdc1f3 CMAKE_TOOLCHAIN_FILE: Improve recovery from changed compiler or toolchain file
Replace __CMAKE_DELETE_CACHE_CHANGE_VARS_ with a set of changed
variables in cmState to avoid interference from scripts and simplify
handling of changed variables.

Errors during configure step will block re-configure when the toolchain
file has changed. Downstream errors can be caused by failing in
EnableLanguage without an error, behavior introduced in 7a989ed58a
(CMAKE_TOOLCHAIN_FILE: Detect path changes and reset cache, 2026-06-24).
Errors directly related to a changed toolchain file should be fixed by
using the new one.

Trigger a fatal error when the toolchain file change is detected to
avoid wasteful configure that will be reset anyway, then re-configure
only for that specific case. Avoid re-configuring multiple times.

Fixes: #27867
2026-07-03 09:25:33 -04:00
Aiden Woodruff 7a989ed58a CMAKE_TOOLCHAIN_FILE: Detect path changes and reset cache
If the path to the toolchain file changes then anything in the cache
that's derived from the toolchain may need to be recomputed.  Detect
this case and start a fresh build.

Issue: #27867
Signed-off-by: Aiden Woodruff <aiden.woodruff@kitware.com>
2026-06-29 12:09:16 -04:00
Brad King 26e79ed299 Fix regression on reconfigure with unnormalized -DCMAKE_<LANG>_COMPILER=
Since commit 3f2a5971c0 (Modules: CMAKE_*_COMPILER convert path to cmake
path, 2023-12-02, v3.29.0-rc1~292^2) we normalize the path to the
compiler.  Update our logic that checks whether the compiler has changed
to account for path normalization.

Fixes: #25883
Issue: #25456
2024-04-10 12:03:17 -04:00
Brad King 1d485a8b45 Tests/RunCMake/CompilerChange: Simplify test cases 2024-04-10 11:55:30 -04:00
Daniele E. Domenichelli 15610bb5b1 Drop use of configure_file IMMEDIATE option
Since commit 7d47c693 (Drop compatibility with CMake < 2.4, 2013-10-08)
we no longer need to use the configure_file IMMEDIATE option to support
compatibility modes less than 2.0.
2013-11-13 10:12:17 -05:00
Brad King e83e6a1c8c Test Unix Makefiles generator support for changing compilers
Add RunCMake.CompilerChange test to cover use of -DCMAKE_C_COMPILER=cc
to change the compiler of an existing build tree.  Also test for proper
failure with -DCMAKE_C_COMPILER="" and no CC in the environment.
2013-02-20 08:01:06 -05:00