Code extracted from:
https://gitlab.kitware.com/utils/kwsys.git
at commit ea3b2a5a965edbc762ff8c3331742603d054bc37 (master).
Upstream Shortlog
-----------------
Brad King (3):
badc3d09 Process: Fix compilation on Windows with WIN32_LEAN_AND_MEAN
c54df4be cmake: Modernize add_definitions calls to add_compile_definitions
1cda2290 cmake: Compile with WIN32_LEAN_AND_MEAN on Windows
Matthew Woehlke (2):
d5b086a9 SystemTools: Fix compilation on Windows with WIN32_LEAN_AND_MEAN
bd32c8f4 SystemInformation: Fix compilation on Windows with WIN32_LEAN_AND_MEAN
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
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
Iterating a JSON array with GET re-parses the entire string on every
call, so walking N elements is O(N^2). ARRAY_SPLIT parses the array
once and returns its elements as a CMake list, letting each element be
queried individually in linear total time.
Each element is re-serialized as compact JSON and encoded to survive
CMake list parsing: '[' and ']' inside strings are emitted as \u005B
and \u005D, and ';' is escaped as '\;'. Every element therefore stays
valid, re-queryable JSON.
Fixes: #27985
Propagates variables set in enable_language() logic up variable scopes
so that the language can be used by targets in the ancestor directories.
Works through block() and function() scopes as well. The
add_subdirectory() call can be thought of as the effective call site for
enabling the language. The same holds for endblock() and the actual
function call.
Adds a policy CMP0220 to control this behavior. As the language is
"enabled" at each ancestor scope, the policy is checked. If OLD, the
language is not enabled at this scope and the ones above.
Closes: #27881#27508#27389
Related: #26751#27564
Since this generator was added, it enforced availability of `CMAKE_AR`
during `enable_language`. These days, the ABI detection and/or check
for a working compiler have already been run via `try_compile`, so if
the archiver is required but missing we will have already failed. Drop
the early generator-specific enforcement that `CMAKE_AR` has been found.
It's needed only if the project actually creates an archive.
Reply file names embed the configuration name verbatim. Reconfiguring
a build tree with a build type that differs from the previous one only
in case (e.g. Debug -> debug) makes CMake write a reply whose name also
differs only in case from the existing file. On a case-insensitive
filesystem the write is skipped because the name already exists, but
RemoveOldReplyFiles compared on-disk names to the just-written names
textually and deleted the surviving file, leaving the reply index
citing a target or directory reply that no longer exists on disk.
Prune reply files by file identity via cmSystemTools::GetFileId instead
of by name, so an on-disk entry that aliases a reply we just wrote is
kept. An entry whose identity cannot be obtained is retained rather
than deleted.
Fixes: #28022
Creates the policy scope after the variable scope instead of the other
way round. This ensures that the cmStateSnapshot which the policy is
registered to is the same as the one created with the variable scope so
that reading a policy from the parent snapshot does not incorrectly read
policies from the new snapshot.