7c3ca57b91 MSVC,Clang: Set CMAKE_CXX_COMPILER_PREDEFINES_COMMAND for the MSVC ABI
0fd711348c Autogen: Pass WIN32 to moc when targeting the MSVC ABI
4a4a654814 Autogen: Keep stderr out of the generated moc_predefs.h
1c1258ad95 cmWorkerPool: Allow capturing process stderr separately
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !12517
The variable was only set by the GNU-like compiler modules, so AUTOMOC
never generated a moc_predefs.h for compilers targeting the MSVC ABI
and moc parsed headers without the compiler's predefined macros.
MSVC dumps its predefined macros with '/PD', which needs the conforming
preprocessor. Require VS 2019 16.8, because 16.7 and older ignore the
flag with warning D9002 and emit no macros at all. clang-cl takes '-dM'
through '-Xclang'. Both also echo the preprocessed source, so feed them
an empty translation unit. clang with the GNU driver is excluded from
'Compiler/GNU' as well when it simulates MSVC, so give it the usual
'-dM -E' command there.
Fixes: #28093
Previously a versioned name in a later search path was preferred
over an unversioned name adjacent to the compiler. Consider all
names in each directory before moving to the next directory.
Extend commit a8e7a1047a (GNU: Do not use -isystem with gfortran,
2015-03-26, v3.3.0-rc1~292^2) to cover classic Flang too. It does
not search system include directories for Fortran `.mod` files.
Follow up commit ed48feeae8 (clang-cl: Add support for C++ modules,
2026-03-27, v4.4.0-rc1~428^2). Prevent clang-cl from interpreting
absolute source paths as flags.
Fixes: #28036
When Clang targets the MSVC ABI, discover the MSVC standard library's
import-std metadata discovery through the MSVC module logic. Also
extend the latter to use `CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES`
and honor `CMAKE_CXX_STDLIB_MODULES_JSON`.
Closes: #26761
Signed-off-by: Sharadh Rajaraman <r.sharadh@outlook.sg>
Fix the version check from commit 0aeeb8160c (CUDA: Add support for
cuda_std_20 for nvcc 12.0+, 2022-12-09, v3.25.2~21^2). Align the
minimum version of MSVC for supporting C++20 through `nvcc` with the
version present in `MSVC-CXX.cmake` .
Introduce a mechanism (via the private and undocumented `ISSUE_WARNING`
option to the `cmake_policy` command) to allow built-in modules to issue
policy warnings. Update modules to use this.
This allows modules to issue policy warnings with the `CMD_POLICY`
diagnostic type, which is consistent with internally issued diagnostics.
This also tends to simplify the logic for issuing such warnings in much
the way the helpers introduced in the previous commit did for the C++
code.
On most platforms we create shared libraries with `-shared` by default,
but on AIX we add `-Wl,-bnoipath` before the default is applied.
Explicitly specify `-shared` for LLVMFlang instead.
Also add compilation flags for position-independent code.
Fixes: #27818
The path-detection routine which sets a default value for
'CMAKE_CXX_STDLIB_MODULES_JSON' is too strict. If the variable is
already set then no additional detection is needed by cmake.
This is relevant when compiling with clang and linking against
Microsoft's STL.
Significant changes on the next major version of the IAR compiler
required some changes in CMake:
- __IAR_COMPILERBASE__ offers a fine grained versioning option
in comparisom with __IAR_SYSTEMS_ICC__, which only referred
to the IAR internal platform version.
- C++20 Language support added for Arm (v10.10.1+), where libc++
is used by default.
The `nagfor` compiler driver does not invoke the linker directly.
Instead it runs the system C compiler driver, which then invokes the
linker. Passing `@` to NAG Fortran expands the response file before
it reaches the linker, which might lead to too long linker lines.
`-Wl,@`, used since commit 10d6c3a635 (NAG: Pass response files
through front-end to the linker, 2018-08-01, v3.13.0-rc1~244^2), can
lead to wrong placement of the response file on the linker line and
doesn't work at all when the response file is the only object file
passed to the NAG Fortran frontend.
Instead use `-xldarg @` to pass a response file through to the linker
without any intermediate expansion. However, the response file
generated by Ninja can contain flags meant for the compiler driver,
so we need to disable response files for these flags altogether.
Fixes: #23577
Since commit 10d6c3a635 (NAG: Pass response files through front-end to
the linker, 2018-08-01, v3.13.0-rc1~244^2) we use `-Wl,@` instead of `@`
in order to pass the response file through the `nagfor` compiler driver
to the linker. However, this is not needed for the archiver. Create
a separate rule variable so we can use different response file flags
for archiving and linking.
Issue: #23577
Add bare minimum functionality to compile C code and link on Windows.
Explicitly label tests that are expected to work with `CFLAGS=-Ze`.
Leave out documentation for now because this is not usable in general.
Issue: #21536
Inspired-by: Serguei E. Leontiev <leo@sai.msu.ru>
Since commit 4a4986d28a (cxxmodules: support command templates for BMI
compilation, 2026-03-25, v4.3.1~2^2~1) we can express module interface
unit compilation to either object files or BMI-only in a way that works
with `clang-scan-deps` and `clang-cl` together.
Fixes: #25731
7ebb5687ab cmGeneratorTarget: use typename for `flag`
4a4986d28a cxxmodules: support command templates for BMI compilation
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11871
Some compilers (Clang) warn when using their BMI-only flag with `-c`.
Support a complete template for BMI compilation rather than an
additional flag to support such toolchains.
Fixes: #27600
Before it would result in us writing the unescaped backslashes to
`CMakeCXXCompiler.cmake` resulting in invalid escape characters causing
the configure to error out.
Several problems with this feature came up while testing 4.3.0-rc1.
These include both broken stdlib distributions and regressions in our
implementation of the feature since CMake 4.2.
Revert commit 70c1f0f43d (Experimental: Remove import std experimental
gate, 2026-02-04, v4.3.0-rc1~61^2) except for its incidental fixes.
Remove the 4.3 release notes related to `import std`.
Rotate the experimental gate's UUID.
Issue: #27426
Issue: #27597
Issue: #27626
Issue: #27635
And change checks to look for a value rather than definition. This fix
keeps the same set of test cases in `RunCMake.CXXModules` selected as
before.
Fixes: #27589
Previously, `CMAKE_<LANG>_LINK_FLAGS` was an undocumented variable used
for linking executables only. Re-spell that variable mirroring the
existing spellings for shared and module libraries, and add policy
CMP0210 to preserve compatibility.
Then, repurpose `CMAKE_<LANG>_LINK_FLAGS` to provide a variable to be
used for per-language link flags for all target types, along with a
per-configuration variant. These are added to the `<LINK_FLAGS>` rule
placeholder in the generators.
Fixes: #21934
Relates: #25620
Co-authored-by: Brad King <brad.king@kitware.com>