1442 Commits
Author SHA1 Message Date
AJIOB 0aa1eaf506 Source: Reduce string allocations, part 4 2026-09-22 11:37:41 +03:00
Marc Chevrier 386d1d874c Add support of custom rules
Fixes: #27383
2026-09-20 11:43:10 +02:00
Marc Chevrier a53691b73a cmCustomCommand: reduce raw pointer usage 2026-09-14 18:24:48 +02:00
Daksh Mamodiya 63316be823 TEST_INCLUDE_FILES: Evaluate generator expressions in include paths
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
2026-07-23 18:58:04 +02:00
Matthew Woehlke a5a9ec9113 TargetTypes: Extract target-related types to dedicated header
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.
2026-07-01 14:44:11 -04:00
Marc Chevrier faeeac60e8 Add SOURCE_GROUP properties for file set and source file
Fixes: #27627
2026-06-24 16:01:23 +02:00
Marc Chevrier 6043014d1d source_group(): Add file set support 2026-06-23 14:55:26 +02:00
Marc Chevrier c06d409f12 FILE_SET: add SKIP_PRECOMPILE_HEADERS property support 2026-06-01 18:39:23 +02:00
Brad King f29a0c4713 Merge topic 'fileset-manage-UNITY_BUILD-exclusion'
7d892786d8 FILE_SET: manage unity build exclusions based on file set type

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !12093
2026-05-26 16:17:35 -04:00
Marc Chevrier 7d892786d8 FILE_SET: manage unity build exclusions based on file set type
This complements commit 5f7a7aa263 (FILE_SET: add SKIP_UNITY_BUILD_INCLUSION property support, 2026-05-11)
2026-05-21 15:23:43 +02:00
Matthew Woehlke a7415d243a Diagnostics: Simplify issuing policy warnings
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.)
2026-05-20 11:55:13 -04:00
Brad King afad360df9 Merge topic 'cmake-more-diagnostics'
028d3183ad Diagnostics: Add POLICY, EXPERIMENTAL
92e0ca9046 Diagnostics: Show author message for all descendants

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12034
2026-05-16 09:53:27 -04:00
Matthew Woehlke 028d3183ad Diagnostics: Add POLICY, EXPERIMENTAL
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.
2026-05-15 09:57:23 -04:00
Marc Chevrier 5f7a7aa263 FILE_SET: add SKIP_UNITY_BUILD_INCLUSION property support 2026-05-14 10:55:35 -04:00
Matthew Woehlke 42c7a97446 Diagnostics: Add class to record state
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.)
2026-05-07 17:10:46 -04:00
Evan Wilde 635f71737c Swift: Factor out Swift-specific target flags
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.
2026-04-27 10:45:14 -07:00
Brad King c8b631cb8d Merge topic 'swift-cmp0157-exe-linker-flags'
15a6d96359 Swift: Honor CMAKE_EXE_LINKER_FLAGS when CMP0157 is NEW

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11937
2026-04-20 09:38:21 -04:00
Fabrice de Gans 15a6d96359 Swift: Honor CMAKE_EXE_LINKER_FLAGS when CMP0157 is NEW
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
2026-04-17 13:10:24 -04:00
Matthew Woehlke 1309532390 Diagnostics: Use new methods
Find places that are currently relying on diagnostic-specific message
types to issue diagnostics and replace these with calls to the new
diagnostic methods.
2026-04-16 15:10:35 -04:00
Philipp Kolberg b53f020b47 ISPC: Fix object suffix for dotted target names
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`.
2026-04-03 09:37:58 -04:00
Marc Chevrier 5697bcced0 BT<> and cmLocalGenerator: Add helpers functions
* Template remove_BT<> to extract content from BT wrapper
* cmLocalGenerator::AppendDefines which take std::set<> and std::vector<BT<>> as arguments
2026-03-31 09:27:58 +02:00
Baudouin Feildel 313769e766 Rust: Add support for Rust editions with Rust_EDITION target property 2026-03-26 23:15:58 +01:00
Tyler Yankee 858fdd426b add_custom_command: Disallow exe-suffixed targets in DEPENDS
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
2026-03-23 09:50:46 -04:00
Tyler Yankee 58ab03c031 add_custom_command: Update dependency search heuristics
Search for a target with the `.exe` suffix stripped from its name only
if a target by the original name doesn't exist.

Fixes: #27612
2026-03-23 09:49:28 -04:00
Brad King f830af52ec Merge topic 'cmake-diagnostics-methods'
b8b0bf1f27 cmListFile: Use cmMakefile to issue messages
0b65420670 Diagnostics: Use command-line option forms in messages
436bfb628c Diagnostics: Add IssueDiagnostics methods

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !11848
2026-03-21 10:22:14 -04:00
Matthew Woehlke 436bfb628c Diagnostics: Add IssueDiagnostics methods
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.
2026-03-20 14:20:23 -04:00
Baudouin Feildel 881faf67e5 Rust: Switch to building .rs files to .rlib instead of native object files
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.
2026-03-20 09:42:44 -04:00
Baudouin Feildel 942ddcdd36 Rust: Add support for position independent code 2026-03-19 14:25:56 -04:00
Kyle Edwards 987e0af366 GenEx: Add $<TARGET_OBJECTS:...> option to filter on source files
Fixes: #27675
2026-03-10 10:51:43 -04:00
Daniel Pfeifer 48115670b5 cmLocalGenerator: Use cmScriptGenerator::Quote 2026-02-26 14:12:48 +01:00
Brad King e35eb114aa Merge topic 'windows-avoid-short-paths'
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
2026-02-25 09:10:04 -05:00
Robert MaynardandBrad King d314cad7f1 Ninja,Make,FASTBuild: Avoid unnecessary Windows short paths in placeholders
Only the classic Borland `make` and Watcom `wmake` tools need short paths.

Co-authored-by: Brad King <brad.king@kitware.com>
Fixes: #16138
2026-02-24 11:56:23 -05:00
Tyler Yankee 8b350fae71 CMP0210: Warn at most once per CMAKE_<LANG>_LINK_FLAGS variable
Additionally, add more testing for the warning case.

Issue: #21934
2026-02-18 11:44:07 -05:00
Brad King 0873cc190d Merge topic 'pchreuse-copy-depends'
a8cf09d49a PCH: Fix regression in REUSE_FROM that copies the `.pdb` too often

Acked-by: Kitware Robot <kwrobot@kitware.com>
Reviewed-by: Ben Boeckel <ben.boeckel@kitware.com>
Merge-request: !11702
2026-02-18 09:19:39 -05:00
Brad King 40c2adc5c7 Merge topic 'pchreuse-copy-depends' into release-4.3
a8cf09d49a PCH: Fix regression in REUSE_FROM that copies the `.pdb` too often

Acked-by: Kitware Robot <kwrobot@kitware.com>
Reviewed-by: Ben Boeckel <ben.boeckel@kitware.com>
Merge-request: !11702
2026-02-18 09:19:37 -05:00
Brad King a8cf09d49a PCH: Fix regression in REUSE_FROM that copies the .pdb too often
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
2026-02-17 17:14:45 -05:00
Brad King 6ec707312d Make character classification locale-independent
Use ASCII-only ctype operations provided by KWSys String.
These match the "C" locale in which `cmake` has long run.
2026-02-11 11:55:54 -05:00
John Franklin Rickard d932b6fb8d Prefer cmHasSuffix for specific extension checks 2026-02-06 12:27:23 -05:00
John Franklin Rickard e531e7420d Reduce string copies by using View function alternatives 2026-02-06 12:27:13 -05:00
Tyler YankeeandBrad King 98f9874703 cmake: Add per-language link flags for all target types
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>
2026-01-31 19:37:09 -05:00
Tyler Yankee 399288871e cmLocalGenerator: Factor out link flag parsing
Prepare for future reuse of CMP0181's NEW behavior (parsing, `LINKER:`
prefix handling, escaping).
2026-01-29 15:30:59 -05:00
Tyler Yankee 5ecee0db7b cmLocalGenerator: De-duplicate static linker flags lookup
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.
2026-01-29 15:30:56 -05:00
Tyler Yankee bc1847c70b cmLocalGenerator: De-duplicate target property link flags lookup 2026-01-29 15:30:55 -05:00
Tyler Yankee 33a1fc5693 cmLocalGenerator: De-duplicate linker flags lookup 2026-01-29 15:30:44 -05:00
Tyler Yankee 8d720a9a61 cmLocalGenerator: Remove redundant link language error
This is already checked by `cmComputeLinkInformation::Compute`, which
is called first.
2026-01-26 12:19:10 -05:00
Cristiano Carvalheiro a46491d0d3 cmLocalGenerator: Improve performance of source group lookups
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
2025-11-26 20:32:19 +00:00
Cristiano Carvalheiro caf6e782e1 cmSourceGroup: Move FindSourceGroup out of cmMakefile 2025-11-26 18:16:05 +00:00
HannaWAR 2628c52e04 source_group: add genex support
Fixes: #19813
2025-11-24 21:08:46 +03:00
Brad King 8832f78dd6 IWYU: Update for Debian 13 CI job
`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.
2025-11-12 14:54:35 -05:00
Brad King f49b0e6759 IWYU: Update for Debian 13 CI job
`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.
2025-11-12 14:54:16 -05:00