Although there is no `cl -std:c23` flag, the underlying Clang compiler
does have a C23 mode we can activate by passing `-std=c23` through a
`clang-cl` wrapper flag.
Also port the fix from commit 30139913e9 (VS: Restore support for mixing
C++23 and C in one target with clang-cl, 2024-12-09, v3.31.3~10^2).
Fixes: #27038
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Co-authored-by: Brad King <brad.king@kitware.com>
MSBuild adds some `link` flags by default, but for CMake they may not
match what's produced by command-line generators. If these flags are
not specified by the project or user, suppress them.
Fixes: #27004
`Microsoft.Cl.Common.props` adds some `cl` flags by default, but for
CMake they may not match what's produced by command-line generators.
If the `-Zc:wchar_t`, `-Zc:forScope`, and/or `-Zc:inline` flags are
not specified by the project or user, suppress them.
Fixes: #26964
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 474eafe28c (clang-cl: Add support for C++23, 2024-09-13,
v3.31.0-rc1~97^2) we use a Clang-specific flag to enable C++23 since
`clang-cl` has no `-std:c++23` flag, and `-std:c++latest` may enable an
even newer version of C++. However, in `.vcxproj` files there is no way
to express a target-wide `-clang:-std=c++23` flag for only C++ sources
when the target also has C sources. Add a special case to map back to
`-std:c++latest` for targets with C++23 and C together.
Fixes: #26508
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
This boolean setting allows parallel building to be disabled for
individual source files built via `add_custom_command`. Using this
option is equivalent to setting policy `CMP0147` to the `OLD` behavior.
Closes: #26413
Visual Studio Generator: The `VS_TOOL_OVERRIDE` source file property
would previously only be respected for file types that CMake didn't know
how to build out of the box. This change allows the user to override how
any source file is built with a custom build tool, even ones with
standard/recognized extensions such as `.cxx`, `.idl`, etc.
Fixes: #26336
Since commit 67de5b7b82 (VS: Suppress MSBuild default settings affected
by UseDebugLibraries, 2024-02-13, v3.30.0-rc1~538^2~1) we generate an
empty `Optimization` element for the host compiler when there are no C
or C++ optimization flags enabled. The CUDA Toolkit Visual Studio
integration fails with an error if an empty string is inherited from the
host compiler's `Optimization` element. If no CUDA optimization flags
are specified, write an explicit empty `Optimization` element for the
CUDA compiler too.
Fixes: #26144
Implement the target-wide `CXX_SCAN_FOR_MODULES`/`CMP0155` selection
with the `.vcxproj`-wide `ScanSourceForModuleDependencies` setting.
Set the per-source equivalent only when needed for a per-source
`CXX_SCAN_FOR_MODULES` property.
This approach enables Intellisense for interfaces imported from modules.
It is also more consistent with what a user might expect when
investigating the state of module scanning from the VS property panels.
Fixes: #25806Fixes: #25947
Extend commit 67de5b7b82 (VS: Suppress MSBuild default settings affected
by UseDebugLibraries, 2024-02-13) to cover a `Microsoft.Cl.Common.props`
default from VS 2015 and older.
This indicates to MSBuild which configurations are considered debug
configurations. This is useful for reference both by humans and tools.
Issue: #25327
`Microsoft.Cl.Common.props` changes some default settings based on
`UseDebugLibraries`. CMake models its own controls for these settings,
so if the project does not set them, explicitly suppress them to avoid
letting `UseDebugLibraries` affect them.