474 Commits
Author SHA1 Message Date
Brad King 5e52f92a2a try_compile: Add support for toolchain files to query CMP0181
Follow the approach from commit 92320466dd (try_compile: Restore
platform-default link flags in pre-CMP0210 projects, 2026-08-22)
to make the CMP0181 policy setting available in `try_compile`
projects before the toolchain file is loaded.

Fixes: #28108
2026-09-22 11:35:05 -04:00
Taylor Braun-JonesandTyler Yankee 5cced02b9d CTest: Repeat test fixtures with the tests that require them
When ctest repeats tests with its --repeat option, it repeats each test
on its own.  A fixture's setup and cleanup tests therefore run all of
their repetitions back to back, and the tests they bracket repeat inside
a single setup/cleanup pair:

  setup -> setup -> test -> test -> cleanup -> cleanup

Add a FIXTURE_REPEAT_MODE test property to select how a fixture behaves
when its tests are repeated:

* AROUND_ALL_REPEATS: the fixture runs once, around all repetitions of
  the tests requiring it.
* AROUND_EACH_REPEAT: the fixture and the tests requiring it repeat
  together, so every repetition gets a fresh setup and its own cleanup.
* EACH_TEST_SEPARATELY: every test repeats on its own, as before.

The property describes the fixture rather than the test carrying it, so
setting it on any one of a fixture's setup or cleanup tests is enough.

In AROUND_EACH_REPEAT mode the tests of a fixture form a repeat group that
ctest re-queues as a whole once every test in it has finished.  The --repeat
condition then applies to the group the way it applies to an individual
test: until-fail repeats while the whole group passes, until-pass repeats
while any of it does not, and after-timeout repeats while any of it times
out.  Fixtures that share a test repeat together, so a test requiring two of
them still runs once per repetition.

A group is recorded the way a repeating test is: only once it stops
repeating, and with the results of its last repetition.  A group that
until-pass makes pass therefore reports a pass rather than the failure that
made it repeat, a test that DEPENDS on one of the group's tests waits for
the last repetition rather than the first, and `ctest -F` resumes an
interrupted group by running it again from the beginning.

Fixtures that repeat together have to agree on the mode: a test cannot
repeat with one fixture but not with another it takes part in, and a fixture
whose setup and cleanup tests disagree has no coherent behavior.  Report an
error and run nothing in those cases rather than pick an order in which a
test repeats after a fixture it requires has been cleaned up.

Add policy CMP0224 to select AROUND_EACH_REPEAT as the default for fixtures
whose setup and cleanup tests choose no mode themselves.  Record the mode
the policy chose in the generated test file under its own
_CMAKE_DEFAULT_FIXTURE_REPEAT_MODE keyword, so that ctest reads a mode
rather than the policy settings behind it, and so that a mode requested on
one of a fixture's tests wins over the default recorded for its siblings.
Only NEW needs recording: with nothing recorded, ctest already uses the
behavior of CMake 4.4 and below.  Fixtures are common, and the choice of
mode matters only to those who run ctest --repeat, so warn about the unset
policy only when the CMAKE_POLICY_WARNING_CMP0224 variable asks for it.

discover_tests() and gtest_discover_tests() create their tests while ctest
runs or at build time, too late for the policy to reach them, so carry the
setting in effect at their call sites through to the tests they create.

Report the repetition a grouped test belongs to in the "(run N/M)" suffix
of its "Start" line, as ctest already does for a test repeating on its own.

Co-authored-by: Tyler Yankee <tyler.yankee@kitware.com>
Fixes: #21438
2026-09-18 08:29:28 -04:00
Mickaël Germain 7192a2b798 cmake_path: An empty path is not a prefix of any path
cmake_path(IS_PREFIX) and $<PATH:IS_PREFIX> treated an empty path as a
prefix of every path, including another empty path, following
std::filesystem::path.  A prefix that is empty because a variable was
set to an empty value, or because a generator expression argument
expanded to nothing, therefore satisfied a check meant to reject it.

Return false for an empty prefix, in cmCMakePath::IsPrefix so that every
caller shares one implementation and both the plain and NORMALIZE forms
are covered.  Normalizing an empty path leaves it empty, so no separate
handling of NORMALIZE is needed.  Unlike the component comparison, which
follows std::filesystem::path deliberately, IsPrefix has no counterpart
in the standard: it borrows path iteration but the predicate itself is
defined by CMake, so an empty prefix is a gap to fill rather than a
standard answer to override.

Add policy CMP0223 and restore the old result behind it at the two
released surfaces.  The other callers of IsPrefix, source_group() and
the Makefile generator's source classification, take the new behavior
ungated: source_group() rejects an empty TREE argument before reaching
it, and the generator passes the source and binary directories.

The if(PATH_IS_PREFIX) operator, new in this same release, follows the
policy too rather than simply taking the new behavior, so that it agrees
with cmake_path(IS_PREFIX) in every policy state and the parity
assertions in its test hold unconditionally.

Fixes: #28077
2026-09-17 10:05:27 -04:00
Mickaël Germain 860583ceac if: Add PATH_IS_PREFIX operator
Testing whether one path is a prefix of another is possible today with
cmake_path(IS_PREFIX), but the idiom needs a separate statement plus a
scratch variable and takes the prefix as a variable name, so projects
reach for if(path MATCHES "^${prefix}") instead.  That is wrong whenever
the prefix contains a regex metacharacter, and it accepts siblings,
because '^/a/b' matches '/a/bc'.

Add a binary operator where the left operand is the candidate prefix and
the right is the path, matching the operand order of cmake_path(IS_PREFIX)
and $<PATH:IS_PREFIX> so that the same operation reads the same way on all
three surfaces.  Neither operand is normalized, matching the default of
cmake_path(IS_PREFIX) and the existing PATH_EQUAL operator, so '.' and
'..' are compared as ordinary components.  The test is non-strict, purely
lexical, and applies no relative-to-absolute reconciliation.

Add policy CMP0222 for compatibility, modeled on CMP0139.  The keyword
is consumed as an operator only when it appears in the second argument
slot, so a variable named PATH_IS_PREFIX keeps working in unary and
left-operand position.  What the policy covers is such a variable
appearing after another token, as in if(NOT PATH_IS_PREFIX AND other),
which becomes a configure error under NEW.

Since the operator is an if() spelling of cmake_path(IS_PREFIX) and shares
its implementation, test it by asserting the two agree over a corpus of
inputs rather than by restating expected values.  Those are pinned by the
cmake_path(IS_PREFIX) test, so the operator's tests stay limited to what
has no command equivalent, and no platform branching is needed because
parity holds whatever the host path model answers.

Fixes: #28040
2026-09-10 07:09:47 -04:00
Daksh Mamodiya 52c8b8104b cmake_host_system_information: select host vs sysroot for DISTRIB_*
`DISTRIB_*` read os-release under `CMAKE_SYSROOT`, so cross builds got
the target distro from a host-oriented command, and a process-wide
static froze the first result.  Add a `FROM_SYSROOT <bool>` option and
policy `CMP0221` to default to the host, parse per call, and scope
`CMAKE_SYSROOT` so the fallback scripts follow the same choice.

Fixes: #27640
2026-09-02 14:48:36 +02:00
Brad King ca0ed0f66f Merge topic 'swift-cmp0215-update'
e4a37fbf15 Tests/RunCMake/Swift: Add CMP0195 behavior checks
b7a78568c3 CMP0215: Update NEW behavior to require CMP0157/CMP0195 to be NEW

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12407
2026-08-14 06:30:36 -04:00
Evan Wilde b7a78568c3 CMP0215: Update NEW behavior to require CMP0157/CMP0195 to be NEW
Update CMP0215 to avoid attempting to iterate through the flags
looking for `-emit-module-path` ins the user-specified flags. We don't
do this anywhere else in the code. The existing implementation didn't
handle correctly parsing the flag so `-I blah/my-emit-module-path/` and
`-Xcc -emit-module-path ...` would both trigger it, result in the
compiler not emitting any module. Furthermore, it didn't include the
user-specified module path as part of the build graph resulting in an
incorrect build graph that would never resolve.

The only two appropriate layouts for the module are either the flat
binary module file with the name `<module-name>.swiftmodule`, or the
nested form with
`<module-name>.swiftmodule/<module-triple>.swiftmodule`. The noted
Swift-Syntax situation passes the explicit `-emit-module-path` to get to
the latter form. This form is automatically emitted by CMake when
CMP0195 is `NEW`, removing the need for the flag. The Swift project
generally recommends the nested directory structure since it gathers all
of the generated interface outputs from the compiler (textual swift
interfaces, swiftdoc, sourceinfo, and the binary swiftmodule file) in a
single place, and since it uses the module triple in the filename,
cleanly allows fat mach-o binaries on Apple platforms.

Fixes: #28021
2026-08-13 10:14:16 -04:00
Arha Gatram 86759dce81 enable_language: add support for usage in subdirectories
Propagates variables set in enable_language() logic up variable scopes
so that the language can be used by targets in the ancestor directories.
Works through block() and function() scopes as well. The
add_subdirectory() call can be thought of as the effective call site for
enabling the language. The same holds for endblock() and the actual
function call.

Adds a policy CMP0220 to control this behavior. As the language is
"enabled" at each ancestor scope, the policy is checked. If OLD, the
language is not enabled at this scope and the ones above.

Closes: #27881 #27508 #27389
Related: #26751 #27564
2026-08-07 11:05:57 -04:00
Brad King 710b2f582d Merge topic 'fix-cmp0186-typo'
01c8417cd2 Help: Fix typo in example of CMP0186

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12143
2026-06-04 10:22:22 -04:00
Julien Jorge 01c8417cd2 Help: Fix typo in example of CMP0186
For CMake 4.1 and above the result of

    string(REGEX REPLACE "^a" "b" result "aaaa")

is `"baaa"`, not `"abbb"`.
2026-06-04 10:14:19 -04:00
Brad King 4bcb0a1dfa Merge topic 'fix-cmp0211-doc'
228795753f FILE_SET: Fix CMP0211-related documentation

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !12119
2026-06-02 09:19:40 -04:00
Alex Reinking 9d2e85373a macro: Add policy to preserve backslashes in arguments
Preserve backslashes in arguments passed to macros by re-escaping
them before substituting in the macro body, where they will be
parsed again.

Fixes: #19281, #22157, #23641, #25803, #27645, #20891
2026-05-31 14:36:15 -04:00
Matthew Woehlke 228795753f FILE_SET: Fix CMP0211-related documentation
Commit 4f120beea9 (FILE_SET: relax file uniqueness for HEADERS type,
2026-05-10) relaxed the restriction on file uniqueness in file sets, but
did not correctly update all instances of the documentation. Change the
wording to be a bit clearer and update all instances.
2026-05-28 16:53:01 -04:00
Matthew Woehlke db4eb6fb91 CMP0218: Clarify when policy applies
Handling of `CMAKE_{WARN,ERROR}_DEPRECATED` in CMake 4.3 is truly
atrocious; some places look at the non-cache values, while others only
care about the `cmMessenger` state (which is synchronized with the cache
values of said variables). For CMP0218, we do not introduce any new
instances of examining the non-cache values. Try to clarify the policy
description to better state which historic diagnostics are affected, and
which are not.
2026-05-12 13:09:30 -04:00
Marc Chevrier 4f120beea9 FILE_SET: relax file uniqueness for HEADERS type
Enable to declare in multiple sets headers files.

This complements commit 167e903c15 (FILE_SET: enforce uniqueness of files, 2026-03-06)

Issue: #27035
2026-05-11 10:42:39 +02:00
Matthew Woehlke 72e7305c3e Diagnostics: Handle CMAKE_{WARN,ERROR}_DEPRECATED
Update documentation for aforementioned variables, as their use is
deprecated under the new diagnostic system. Introduce a policy which
reintroduces their use to control specific deprecation diagnostics if
the policy is not NEW.

Note that this means there is NO synchronization between the variables
and the new diagnostic state.
2026-05-07 11:07:27 -04:00
Marc Chevrier 5f63b3c6b1 Remove MACROS directory property
It did not always contain all macros.
We have `if(COMMAND)` now instead.

Add policy CMP0217 for compatibility.

Fixes: #27765
2026-04-29 16:43:04 +02:00
Evan Wilde 118ab41984 Swift: Build with a package name by default
Add policy CMP0216 to enable use of the `PROJECT_NAME` as the default
package name for Swift.

Issue: #26886
2026-04-28 15:30:44 -04:00
Roman Lavrov b6367f723b Swift/Ninja: Emit modules separately from compilation
Add policy CMP0215 to emit `.swiftmodule` from a dedicated `-emit-module`
build edge for importable Swift targets in the Ninja generator.
Downstream targets can begin compiling as soon as the module interface
is ready, overlapping with upstream object compilation and linking.

When CMP0215 is NEW and CMP0157 is NEW, separate module emission is
enabled by default.  The `Swift_SEPARATE_MODULE_EMISSION` target
property (initialized by the `CMAKE_Swift_SEPARATE_MODULE_EMISSION`
variable) can override this per target.

The compile edge still passes `-emit-module` so that swiftc continues
to produce `.swiftdoc`; only the `.swiftmodule` output moves to the new
edge.

Also fix swiftmodule dependency edges in cmNinjaNormalTargetGenerator
to use IsLanguageUsed instead of GetLinkerLanguage, so C/C++ targets
whose linker language propagated to Swift do not produce spurious
implicit dependencies.

Closes: #27748
2026-04-24 15:58:18 -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
AJIOB 97455c3d7e file: Add ARCHIVE_* options to specify pathname encoding
Issue: #26903
2026-03-24 14:07:21 -04: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
Marc Chevrier 167e903c15 FILE_SET: enforce uniqueness of files
A file should be unique for a target if specified as part of a file set.

Issue: #27035
2026-03-23 08:37:05 -04: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
Brad King 18c98682f5 Merge topic 'verify-private-header-sets'
b61637f90f File sets: Add verification of private file sets
61df2e15a2 Help: Verification target also sets CXX_SCAN_FOR_MODULES to false
909b54023a File sets: Specify verify file set target names in one place
20219414c3 File sets: Always verify interface files sets of executable targets
c7a1d5ee58 Tests: Rename VerifyHeaderSets tests to VerifyInterfaceHeaderSets

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !11565
2026-01-19 09:27:59 -05:00
Craig Scott 20219414c3 File sets: Always verify interface files sets of executable targets
When VERIFY_INTERFACE_FILE_SETS is set to true on an executable
target, verification of that target's interface file sets was only being
performed if the target's ENABLE_EXPORTS property was set to true.
We now always verify the interface file sets of executable targets,
subject to the new CMP0209 policy. This allows interface file sets to
be verified even for executable targets that do not export symbols.
Interface file sets containing headers that are fully inlined is an
example use case for this scenario. Unit test executables may link
to the executable under test, possibly with $<COMPILE_ONLY:...>.

Issue: #23448 #27046
2026-01-16 18:10:14 +11:00
Brad King 08e1d1001a Merge topic 'fix-cmp0199'
35d5a4fd6d GenEx: Partially restore pre-CMP0199 behavior of $<CONFIG>

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Acked-by: Matthew Woehlke <matthew.woehlke@kitware.com>
Merge-request: !11581
2026-01-13 11:05:11 -05:00
Matthew Woehlke 35d5a4fd6d GenEx: Partially restore pre-CMP0199 behavior of $<CONFIG>
Modify the implementation of policy CMP0199 to only remove the oddball
configuration map matching of `$<CONFIG>` in `NEW` mode, restoring the
old behavior of matching BOTH the consumer's configuration and the
selected configuration of the imported target. It turns out that users
are more dependent on the former than the latter, and while matching
more than one thing is still dodgy, we will likely need to introduce a
new generator expression to match the selected configuration of the
imported target.

Meanwhile, `$<CONFIG>` on targets imported from CPS still only matches
the selected configuration of the imported target, which is the behavior
specified by CPS. However, this can only happen for `$<CONFIG>`
expressions that were generated internally during import.

Update documentation and test cases accordingly.

Fixes: #27487
Fixes: #27495
2026-01-12 10:58:08 -05:00
Matthew Woehlke 2151e5f79d export, install: Improve argument parsing
Modify the `export(EXPORT)` and `install(PACKAGE_INFO)` commands to
actually enforce that certain arguments must be non-empty. With respect
to `export`, this is mainly targeted at CPS export, but ends up
affecting all flavors of `export(EXPORT)` because that is the level at
which argument parsing is performed.

Also, add unit tests to verify that the new rejection of arguments with
missing or empty values is working, update the existing tests due to
changes in error reporting, and remove no-longer-needed manual
validation of an empty `PACKAGE_INFO` argument.
2025-12-09 13:37:01 -05:00
FeRD (Frank Dana) 7f7175e0cd Help: Add target for policy deprecation link
In the policy pages' "deprecated by definition" box, instead of
linking that phrase to the `cmake-policies(7)` manual page, add
a label (`_cmake-policies-intro`) above the "Introduction" section,
and link to that label using the `:ref:` role instead.

This avoids landing the reader at the `cmake-policies(7)` table of
contents, which is now long enough that it's likely to fill their
entire screen unless they scroll down!

As an added bonus, using `:ref:` instead of `:manual:` avoids
applying monospace formatting to the link text.
2025-11-16 06:07:08 -05:00
hanna.rusakovich bf3f69834d file(GET_RUNTIME_DEPENDENCIES): Normalize paths before matching
Regex-based filtering should not have to account for slash differences.
Add policy CMP0207 for compatibility.

Fixes: #26202
2025-11-14 17:23:26 +03:00
Clinton Stimpson 5a18728cec CPack/Archive: Add support for setting UID/GID in archive
Add `CPACK_ARCHIVE_UID` and `CPACK_ARCHIVE_GID` options.

Add a policy to change the default to 0/0 to enable ownership
by root if unpacking as root.

Fixes: #12901
2025-11-08 09:25:08 -05:00
Hanna Rusakovich a73ddd2ddb file(CREATE_LINK): Implement COPY_ON_ERROR for directories
Add policy `CMP0205` for compatibility with projects not expecting this.

Fixes: #27294
2025-10-31 08:42:59 +03:00
AJIOB 6874efb592 MSVC: Always define a character set
When targeting the MSVC ABI, define `_MBCS` by default if the project
does not define `_SBCS` or `_UNICODE`.  Visual Studio has long defined
one of the three character set macros automatically.  For consistency,
define it when compiling for the MSVC ABI with other generators.
Add policy CMP0204 for compatibility.

Fixes: #27275
2025-10-07 09:29:32 -04:00
Brad King 490b6fe1f2 Merge topic 'build-graph-opt-docs'
fac5e622b7 Help/OPTIMIZE_DEPENDENCIES: xref with CMP0154 documentation
03f5ffa2ca Help/OPTIMIZE_DEPENDENCIES: move period outside of parenthetical

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11275
2025-10-02 13:56:27 -04:00
Brad King 9f7179793b Merge topic 'build-graph-opt-docs' into release-4.1
fac5e622b7 Help/OPTIMIZE_DEPENDENCIES: xref with CMP0154 documentation
03f5ffa2ca Help/OPTIMIZE_DEPENDENCIES: move period outside of parenthetical

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11275
2025-10-02 13:56:25 -04:00
Brad King 09aded59f7 Help: Revise CMP0201 documentation using typical wording conventions 2025-10-01 09:23:32 -04:00
Ben Boeckel fac5e622b7 Help/OPTIMIZE_DEPENDENCIES: xref with CMP0154 documentation
Closes: #27250
2025-09-30 22:59:04 -04:00
AJIOB 83bbde5449 MSVC: Define _WINDLL consistently for shared libraries
Visual Studio defines this automatically for `.dll` targets.
For consistency, define it when compiling for the MSVC ABI
with other generators.  Add policy CMP0203 for compatibility.

Fixes: #27253
2025-09-29 18:26:44 -04:00
Brad King 6e1de32c9d Merge topic 'pdb-postfix'
7a154bf4fd GenEx: Add POSTFIX option to $<TARGET_PDB_FILE_BASE_NAME>
5654207925 PDB: Always add the target per-config POSTFIX to .pdb names

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !11235
2025-09-26 09:26:49 -04:00
Marc Chevrier 5654207925 PDB: Always add the target per-config POSTFIX to .pdb names
Manage the POSTFIX target property in the same way as other artifacts
names.  Add policy CMP0202 for compatibility.

Fixes: #27206
2025-09-25 11:00:39 +02:00
Brad King 26413a3e3d Merge topic 'file-GENERATE-CMP0189'
deb7b4b658 file(GENERATE): Record CMP0189 at each call site
9b862e7013 cmGeneratorTarget: Pass genex evaluation context to IsTransitiveProperty

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !11234
2025-09-24 08:45:14 -04:00
Brad King deb7b4b658 file(GENERATE): Record CMP0189 at each call site
Policy CMP0189, introduced by commit b3da9c6d60 (GenEx: Evaluate
LINK_LIBRARIES target properties transitively, 2025-02-24,
v4.1.0-rc1~731^2), takes effect at generation time, and so uses the
policy value as of the end of each directory.  However, some projects
may rely on `file(GENERATE)` with the policy's OLD behavior in order
to extract targets' *direct* dependencies from `LINK_LIBRARIES`.
Pending a first-class solution to that problem, make it easier for
projects to port to the policy's NEW behavior in general while
retaining the OLD behavior in an isolated context.

Fixes: #27220
2025-09-23 11:30:22 -04:00
Brad King c9faddaf74 Merge topic 'doc-CMP0189'
e8d779c935 Help: Document when policy CMP0189 takes effect

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11230
2025-09-23 09:14:16 -04:00
Brad King e8d779c935 Help: Document when policy CMP0189 takes effect
This was left out of commit b3da9c6d60 (GenEx: Evaluate LINK_LIBRARIES
target properties transitively, 2025-02-24, v4.1.0-rc1~731^2).

Issue: #27220
2025-09-22 15:21:05 -04:00
Marc Chevrier 0a4a4d2053 FindPython: NumPy target does not depend on Development.Module
Fixes: #27123
2025-08-25 15:28:41 +02:00
Brad King 46fc0232ae Merge topic 'fix-get-mapped-config'
05ae95c864 cmTarget: Overhaul GetMappedConfig

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !10995
2025-08-25 09:16:53 -04:00
Matthew Woehlke 05ae95c864 cmTarget: Overhaul GetMappedConfig
Create a brand new implementation of `cmTarget::GetMappedConfig` which
prioritized a target's `IMPORTED_CONFIGURATIONS` as the 'source of
truth' for what configurations are available. In particular, this means
that configuration selection when `IMPORTED_CONFIGURATIONS` is set does
not depend on the library type in any manner. The fallback logic also
uses a more consistent 'usability' criteria that should result in more
consistent configuration selection, particularly for `INTERFACE`
targets.

The previous implementation is retained as a separate method for users
requesting the OLD behavior.

Fixes: #27022
2025-08-20 14:44:05 -04:00
Peter Kokot 361af2b480 FeatureSummary: Update documentation
- Refactored and synced module documentation.
- Moved all documentation to the top header comment to make it easier to
  manage and adjust.
- Added table of contents.
- Added intro code block showing how to use this module.
- Described arguments of commands as a list.
- Used word "commands" instead of "functions".
- Added separate examples section with more examples.
2025-08-11 10:32:40 +02:00
Matthew Woehlke 8ac826a5f2 GenEx: Fix evaluation of $<CONFIG> on imported targets
The historic implementation of `$<CONFIG>` had some errors that could
result in multiple configurations matching. First, it always considered
the configuration of the consuming target, even if a consumed imported
target selected a different configuration. Second, it matched the entire
list of `MAP_IMPORTED_CONFIG_<CONFIG>` configurations, even if none of
those were actually selected. The latter in particular is redundant at
best, as we also consider the selected configuration of an imported
target, which is the correct configuration to match for imported
targets. Refactor the implementation so that only one configuration is
considered.

Fixes: #23660
Issue: #27022
2025-07-30 15:12:03 -04:00