Refactoring in commit 2b2344b412 (MSVC: Add abstraction for runtime
checks, 2025-01-22) switched to using local compiler id variables to
recognize compilers that target the MSVC ABI. However, those variables
may be modified modified in a special case for `lang == "RC"` that does
not apply to the ABI check. Check the target ABI before applying the
special case.
Fixes: #26663
Replace our hard-coded default for `/RTC1` with a first-class
abstraction to select runtime checks from an enumeration of logical
names. Add a `MSVC_RUNTIME_CHECKS` target property and corresponding
`CMAKE_MSVC_RUNTIME_CHECKS` variable.
Removing the old default flag requires a policy because existing
projects may rely on string processing to edit them and choose
runtime checks under the old behavior. Add policy CMP0184 to
provide compatibility.
Fixes: #26614
CMake now provides the CMAKE_<LANG>_LINK_MODE variable which specify how
the link step is done. So, the CMAKE_<LANG>_USING_LINKER_MODE variable
is no longer needed.
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
In commit 375e6fdbbe (Link step: use linker dependency linker file,
2023-04-19, v3.27.0-rc1~126^2) we added the `-Wl,--dependency-file,...`
flag for the Ninja generator in a code path shared with the file-api.
This flag is a build system implementation detail and should not be
exposed to file-api clients. Move it to a Ninja-specific code path.
Fixes: #26498
Add a way to specify, in a portable way, to raise an error for any
warning during the link step. For that purpose, define:
* CMAKE_LINK_WARNING_AS_ERROR variable
* LINK_WARNING_AS_ERROR target property
Fixes: #25343
Rerun CMake when `cmake_install.cmake` or `CTestTestfile.cmake` are out
of date. This enables regeneration if a subdirectory is removed before
invoking `ninja`.
Fixes: #26396
Since commit d46d8df0ed (ENH: Re-implemented cmGeneratedFileStream to
... replace the destination file atomically, 2004-11-03, v2.4.0~2578) we
have generated `cmake_install.cmake` scripts with "copy-if-different"
semantics such that their timestamp is only updated when their contents
change. In commit d395b563ed (ENH: ... test files are written by local
generator, 2005-04-24, v2.4.0~1842) we copied the approach for
generating `CTestTestfile.cmake` scripts.
In both cases, preserving timestamps is not needed and was only a side
effect of using `cmGeneratedFileStream` to replace the generated files
atomically. Drop the "copy-if-different" semantics and always update
their timestamps so it is possible to know when they have been
regenerated.
The following variables now support the LINKER: prefix:
* CMAKE_SHARED_LIBRARY_CREATE_<LANG>_FLAGS
* CMAKE_SHARED_MODULE_CREATE_<LANG>_FLAGS
* CMAKE_<LANG>_LINK_FLAGS
`CollapseFullPath` has two use cases:
1. Normalize input paths from command-line arguments and environment
variables. On Windows, load their on-disk capitalization.
2. Simplify paths constructed internally. These should already have
the correct capitalization.
Audit all `CollapseFullPath` call sites and code paths leading to them.
Replace those calls that normalize input paths with calls to
`ToNormalizedPathOnDisk` to express that they need the on-disk case.
By making this distinction we will later be able to remove the on-disk
capitalization lookup `CollapseFullPath`, thus eliminating disk accesses
from internal path processing.
Issue: #20214
Add a target property that will be read on unity file generation to
attempt to use a relative path to the source file from the CMake Source
Directory or the generated unity file. Additionally add the CMake
Source Directory and the CMake Binary directory to the include path of
the generated unity files.
Closes: #26352
By specifying CODEGEN as an argument to add_custom_command the
custom command will be added to a codegen build target.
The intent is to provide a convenient way for users to get
their generated files without having to build the whole project.
This can be helpful for code analysis tools which can be useful
for IDEs and CI.
Most generators now support this character after escaping and quoting
cleanups over time. Disallow it only on generators that do support it.
Fixes: #25604
The generated `cmake_install.cmake` script no longer blindly tries to
create files `install_manifest_<component-name>.txt` that partly
consists of the verbatim name of a component, which might contain
characters that are not supported on the platform / filesystem.
Instead, if the component's name contains a (possibly) problematic
character its MD5 hash will be used:
`install_manifest_<component-hash>.txt`
Since commit f593b354da (PCH: Add support for multi architecture iOS
projects, 2020-04-02, v3.18.0-rc1~414^2) we use per-arch .pch files
even when compiling for just the host architecture on macOS arm64.
This breaks with compilers that do not support `-Xarch_` flags, such
as GCC. Avoid using per-arch .pch files in single-architecture builds.
Fixes: #25514
Issue: #20497
Wire up the flags needed to support module libraries built and used with
Swift. We need to pass `-bundle` to the linker when linking module
libraries on Darwin, and we need to pass `-export-dynamic` to the linker
when emitting an executable that exports symbols on Linux. This patch
wires up `CMAKE_SHARED_MODULE_CREATE_Swift_FLAGS` and
`CMAKE_SHARED_MODULE_LOADER_Swift_FLAG` on Darwin, and hooks up
`CMAKE_EXE_EXPORTS_Swift_FLAG` on Linux in order to support passing
things correctly.
We can't expose `CMAKE_EXE_LINKER_FLAGS` to Swift, as it contains flags
that the Swift compiler doesn't recognize, but the other
language-specific variables are safe to expose.
801ae06952 LINKER_TYPE: Support MOLD only on GCC versions that support it
939ac5287e LINKER_TYPE: fix spelling error in message
922883782b LINKER_TYPE: Document that linker tool should be in the PATH
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9334