The TEST_INCLUDE_FILE(S) directory properties were written verbatim into
CTestTestfile.cmake, so a $<CONFIG>-parameterized include path could not
select a per-configuration script and failed at ctest time.
Evaluate generator expressions per include entry in
cmLocalGenerator::GenerateTestFiles():
* Entries without a generator expression are emitted unchanged.
* On single-config generators a genex entry is evaluated once and
emitted as one unconditional include.
* On multi-config generators it is evaluated for every configuration;
a config-independent result collapses to one unconditional include,
otherwise each non-empty per-config result is guarded by a
CTEST_CONFIGURATION_TYPE branch, mirroring add_test(). An entry that
evaluates to empty adds no include.
Promote cmScriptGenerator::CreateConfigTest to a public static helper so
the include guards reuse the exact add_test() config-test encoding; the
instance overloads now delegate to it. Evaluated results are quoted via
cmScriptGenerator::Quote, while plain entries keep their raw
serialization.
Fixes: #27941
Move some target related enumeration types from `cmStateTypes.h` to a
new header, as these really aren't "state" types. Also, make
`TargetType` a strongly-typed enumeration.
Add and use a couple helper functions for issuing policy warnings. This
improves consistency and allows some simplification of many call sites.
(One or two instances in particular are greatly simplified.)
Add new diagnostic categories CMD_POLICY and CMD_EXPERIMENTAL, both as
children of CMD_AUTHOR. Use the former when issuing policy warnings. Use
the latter when issuing experimental feature warnings.
Create new cmDiagnosticContext used to capture the diagnostic state for
instances when the issuing of a diagnostic might happen at a point far
separated from processing the CMake command ultimately responsible for
the diagnostic. (This is particularly the case for diagnostics that get
emitted during the generation phase.) In such cases, it is preferred
that we record the diagnostic state that pertained when the ultimately
instigating command was processed, so that users can control the
diagnostic in a natural manner. Copying the entire cmStateSnapshot is
unreasonably expensive; this will provide a lighter-weight mechanism for
capturing the relevant diagnostic state for later use.
Since it is almost universal that the points where we would capture this
state also capture a stack trace (which is likewise used to issue
diagnostics), the new class contains a stack trace, and replaces the
stack trace in some diagnostic calls. (In some instances, an overload
which implicitly converts a stack trace to the new context class is
retained for convenience. These will behave the same, since capturing
diagnostic state is an optional function of the new class.)
Swift started the trend of piling language-specific target flags in
`cmLocalGenerator::AddLanguageFlags`. Other languages have added their
own under language-specific `Add<Lang>TargetFlags`.
I'm refactoring where Swift piles on its language-specific target flags
to match the pattern other languages are using.
Since commit 56e5cea600 (Swift: Support module libraries with
command-line build systems, 2024-03-23, v3.30.0-rc1~245^2) we pass
`CMAKE_SHARED_LINKER_FLAGS` when linking Swift shared libraries if
CMP0157 is NEW. For consistency, pass `CMAKE_EXE_LINKER_FLAGS` when
linking executables. Add policy CMP0214 for compatibility.
Fixes: #26154
Find places that are currently relying on diagnostic-specific message
types to issue diagnostics and replace these with calls to the new
diagnostic methods.
ISPC target names containing dots, such as `avx10.2dmr-x16`, produce
output files with underscores in the ISA suffix (e.g. `_avx10_2dmr`).
The `ComputeISPCObjectSuffixes` function did not account for this,
causing a mismatch between the predicted and actual object file names.
Replace dots with underscores in the extracted target suffix to match
ISPC's `ISAToString()` behavior. Also add mappings for `sse4.1`
and `sse4.2` target name variants, which ISPC both maps to `sse4`.
Two targets whose names differ only in a `.exe` suffix create a
conflict when adding target- and file-level dependencies for a custom
command. Add CMP0212 to provide compatibility with the old behavior.
Issue: #27612
Create methods to issue diagnostics. Diagnostics are similar to
messages, except that they are associated with a diagnostic category,
and the diagnostic state determines their severity. Also, add overloads
of methods to issue messages and diagnostics that accept a backtrace, as
a number of places must currently bypass layers in order to pass a
custom backtrace. These are also sub-optimal because the lower level
APIs require the diagnostic state to be explicitly passed by the caller,
which we would prefer to avoid whenever possible.
Each Rust source file given to a target is considered a separate crate
root. There's a concept of a "main crate root", which is the `.rs` file
that is given to the final linker phase in CMake. Other Rust source file
in a target are built as rlib separately.
The project can still build `.rs` files into object files by setting the
Rust_EMIT property on the desired source file.
d314cad7f1 Ninja,Make,FASTBuild: Avoid unnecessary Windows short paths in placeholders
8099fe4436 CMakeParseImplicitLinkInfo: Fix detection of MSVC link.exe from quoted path
c211b5b7f3 Makefile: Pass includes response file using native path style
728b8b34c2 IAR: Fix `ichecks` invocation on Windows when not using short paths
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11717
Since commit 99bdf2ae16 (cmLocalGenerator: add PDB copying dependency on
its script, 2025-06-16, v4.2.0-rc1~481^2~8) the copy is repeated
whenever the copying script is updated. Avoid updating the copy script
timestamp when it does not change.
Fixes: #27608
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>
Be sure to obey CMP0181 by not applying `LINKER:` expansion etc. to
the flags in this variable, unlike shared library, module library, and
executable targets.
Introduce an index from source file to source group in
`cmLocalGenerator` to make lookups significantly more efficient
during the source group generation, which could be particularly
slow when dealing with thousands of source files.
Falls back to the recursive lookup when the source file is not present
on the index, which is more likely to happen when dealing with
regex-based sources.
Fixes: #27359
`include-what-you-use` diagnostics, in practice, are specific to
the environment's compiler and standard library. Update includes
to satisfy IWYU for our CI job under Debian 13. Some patterns:
* Types named in virtual `override` signatures no longer require
includes since the overridden signature already names them.
* A function argument's type needs to be included even if its constructor
is called only by implicit conversion. For example, constructing a
`std::function` from a lambda now requires `<functional>`.
* Some prior mysterious `<type_traits>` inclusions are no longer required.
`include-what-you-use` diagnostics, in practice, are specific to
the environment's compiler and standard library. Update includes
to satisfy IWYU for our CI job under Debian 13. Some patterns:
* Types named in virtual `override` signatures no longer require
includes since the overridden signature already names them.
* A function argument's type needs to be included even if its constructor
is called only by implicit conversion. For example, constructing a
`std::function` from a lambda now requires `<functional>`.
* Some prior mysterious `<type_traits>` inclusions are no longer required.