1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-14 02:08:27 +08:00

440 Commits

Author SHA1 Message Date
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
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
Benjamin Buch
41aea12941 Do not define CMAKE_PARENT_LIST_FILE in CMakeLists.txt
Add policy `CMP0198` for compatibility.

Issue: #25026
2025-07-15 11:51:45 -04:00
Ben Boeckel
b634998727 Help: add and make references to generators consistent 2025-06-12 21:25:24 +02:00
Brad King
92d6126450 MSVC: Move link -machine flag out of CMAKE_*_LINKER_FLAGS
The `CMAKE_{EXE,SHARED,MODULE,STATIC}_LINKER_FLAGS` variables are
not language-specific, so multiple languages' toolchains may disagree
about if/how to pass the flag through a compiler driver to the linker.
Furthermore, carrying the flag in public-facing variables allows projects
or users to change it even though it is required.  Add policy CMP0197
to remove the flag from the public-facing variables and generate it
automatically instead:

* For command-line generators, add the `-machine:` flag to the
  linker and archiver rule variables.

* For Visual Studio generators, we do not need to explicitly add the
  link `-machine:` flag.  MSBuild automatically adds it, and the new
  behavior actually removes a duplicate we generated previously.

Issue: #21934
2025-06-05 09:16:54 -04:00
Peter Kokot
535734ee16 GNUInstallDirs: Update documentation
- Added intro code block showing how to include this module.
- Reworded module introduction.
- Used "command" instead of "function".
- Reworded command arguments and descriptions.
- Added the "See Also" section.
2025-05-30 02:35:45 +02:00
Brad King
39da33ae81 CMakeDetermineVSServicePack: Add policy to remove this module
It has been documented as deprecated since CMake 3.0.
2025-05-28 09:47:06 -04:00
Peter Kokot
b2e7736d81 CheckIncludeFile*: Sync documentation
- Added intro code blocks showing how to include these modules.
- Used "command" instead of "macro".
- Mentioned policy CMP0075.
- Added additional example to CheckIncludeFile showing how to use
  CMAKE_REQUIRED_* variable.
2025-05-27 00:16:57 +02:00
Evan Wilde
1711e86d6c Swift: Generate nested swift modules in build dir
The nested Swift module structure is recommended for Swift projects.
This structure has an outer directory called
`<Swift_MODULE_NAME>.swiftmodule` that contains generated files for the
interface. The binary swift modules, textual swift interface, and other
supplemental outputs that make up the interface to a Swift library all
go in this outer directory with the Swift module triple as the filename
followed by the appropriate file extension based on what that file
contains.

Issue: #19284
2025-05-21 10:19:58 -07:00
Brad King
14212494bb ASM: Guard exclusion of MSVC C/CXX compiler with a policy
Since commit 6baf65ec46 (ASM: Do not consider MSVC C/CXX compiler for
generic ASM, 2025-04-08) we no longer mistake `cl` for an assembler.
However, some projects unconditionally enable ``ASM``, which worked
on Windows only due to that bug.  Restore compatibility with such
projects by guarding the change behind a new policy ``CMP0194``.

Fixes: #26907
Issue: #26617
2025-05-03 13:18:19 -04:00
Brad King
07a30dc075 Merge topic 'GNUInstallDirs-get-absolute-install-dir'
cc6dbd194c GNUInstallDirs: Cache CMAKE_INSTALL_* with leading usr/ for install prefix /
a7fcb1320c GNUInstallDirs: Make GNUInstallDirs_get_absolute_install_dir a function
03e796f9ab GNUInstallDirs: Move the common handler for `SYSCONFDIR` and `LOCALSTATEDIR`

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10584
2025-04-30 09:52:43 -04:00
Cristian Le
cc6dbd194c GNUInstallDirs: Cache CMAKE_INSTALL_* with leading usr/ for install prefix /
As a consequence, `GNUInstallDirs_get_absolute_install_dir` does not
alter the `var` argument (the relative path argument).

Closes: #26834
Signed-off-by: Cristian Le <git@lecris.dev>
2025-04-29 13:49:42 -04:00
Peter Kokot
c9d86e8beb FindFLEX: Update documentation
- Updated and synced module documentation with other similar find
  modules.
- Used lowercase style for commands across the docs.
- Commands documented with indentation.
- Command arguments described as a list separately.
- Used "commands" instead of "macros".
- Extended examples section.
- Added example showing how to use found Flex library by creating an
  imported target inside a project. Fixes: #18718
2025-04-29 06:33:47 +02:00
Peter Kokot
e0c4e8ecf4 FindBISON: Update documentation
- Updated and synced module documentation with other similar find
  modules.
- Documented bison_target() command indented relative to the title.
- Command arguments described as a list separately.
- Used "command" instead of "macro".
- Used lowercase style across the docs.
- Extended examples section.
2025-04-29 06:18:15 +02:00
Alex Turbov
9784834b4c Help: Use *.rst extension for included files
So, editor(s) can correctly highlight the RST syntax in the included files.
2025-04-14 03:07:46 +04:00
Brad King
cc2d986fdf Merge topic 'GNUInstallDirs-special-cases'
4ed399ccfb GNUInstallDirs: Change special path defaults to absolute
7566a477f7 GNUInstallDirs: Factor out helper for special absolute path logic
42dfcbf1a5 GNUInstallDirs: Refactor LIBDIR default calculation
9789f7d05e GNUInstallDirs: Add internal helper to compute specific defaults
83f44bbf53 GNUInstallDirs: Factor out helper to compute system type
0c9b6aa9e4 GNUInstallDirs: De-duplicate description of defaults
18e1341950 GNUInstallDirs: Move defaults from arguments to variables
9f41a67fce GNUInstallDirs: Reduce duplication of CMAKE_INSTALL_ prefix
...

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !10542
2025-04-10 08:57:49 -04:00
Cristian Le
4ed399ccfb GNUInstallDirs: Change special path defaults to absolute
Add policy `CMP0192` for compatibility.

Closes: #25852
Signed-off-by: Cristian Le <git@lecris.dev>
2025-04-09 11:31:43 -04:00
Peter Kokot
67055f5b3a CMakeDependentOption: Update documentation
This updates the module documentation to be more synced with other
modules. Also, this module on the first glance doesn't do what most
people might think. Because when condition evaluates to false, internal
cache remains with the same value, and a local variable is created with
the value provided in the last argument.

- Command arguments described separately and their placeholders renamed
  to more intuitive names.
- More examples added, starting with a very basic syntax usage to more
  complex ones, each described in more details.
- Each example has include() added to be more clear that this is a
  module command.
2025-03-31 02:42:49 +02:00
Craig Scott
eab202ac9d Merge topic 'doc-4.0-release-cleanup'
5dff5e2f7f Help: Fix typo in 4.0 release notes for CPack archive generator
713968c280 Help: Improve wording of docs related to MSVC runtime checks
316aaa6cdd Help: Fix inaccurate wording for CMAKE_XCODE_SCHEME_... variables

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10545
2025-03-30 06:00:08 -04:00
Craig Scott
713968c280 Help: Improve wording of docs related to MSVC runtime checks 2025-03-28 14:23:47 +11:00
Brad King
2b8b17106c FindCABLE: Add policy to remove this module
CABLE has not been maintained in a long time.
2025-03-27 09:48:49 -04:00
Marc Chevrier
5c1521c54d FindPython: enforce artifacts consistency when cross-compiling
Fixes: #26696
2025-03-05 17:11:56 +01:00
Brad King
b3da9c6d60 GenEx: Evaluate LINK_LIBRARIES target properties transitively
The `LINK_LIBRARIES` and `INTERFACE_LINK_LIBRARIES` target properties
establish the graph of link dependencies used to propagate usage
requirements transitively.  Therefore the `$<TARGET_PROPERTY:...>`
generator expression should evaluate them transitively as it does for
other transitive properties.  Add policy CMP0189 for compatibility.

Fixes: #26709
Issue: #12435
2025-02-24 11:43:47 -05:00
Brad King
2123244746 FindGCCXML: Add policy to remove this module
GCC-XML has been superseded by CastXML for a long time.

Closes: #26687
2025-02-17 11:35:25 -05:00
Evan Wilde
321c647640 Include source file without an extension after the same name with an extension
CMP0115 requires that source files listed in CMake must include their
file extension, but there are cases when projects have different source
files with the same name, but one with an extension and one without.
In the current state, CMake will ignore the file without the extension
an always map it to the file with an extension.

```cmake
add_library(foo bar.c bar)
```

In the above example, the target `foo` will only recognize and depend on
`bar.c` and miss the file `bar` unless `bar` comes before `bar.c` in the
source list.
This issue also affects how custom commands emit files.

This change adds a new policy to recognize files with and without a file
extension as different files, both when building targets, and when they
are being created.

Fixes: #26058
2025-02-14 10:01:10 -05:00
Nikita Nemkin
5d039f3be3 regex: Match ^ at most once in repeated searches
When doing successive matches, track the input start and current search
start positions separately to prevent the `^` anchor from matching in
the middle of the string.  Add policy CMP0186 to provide compatibility.

Issue: #26629
Fixes: #16899
2025-02-13 20:00:02 +05:00
Brad King
d65f522a50 Merge topic 'FindRuby-compat-vars'
2d86cf314f FindRuby: Drop upper-case RUBY_ results in favor of Ruby_ variables

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10273
2025-02-02 07:03:10 -05:00
Brad King
2d86cf314f FindRuby: Drop upper-case RUBY_ results in favor of Ruby_ variables
Add policy CMP0185 for compatibility.

Fixes: #26640
2025-02-01 07:12:30 -05:00
Nikita Nemkin
51e4d81f16 Help: Remove accidental blockquotes around lists
Indenting a list relative to the previous paragraph creates
a blockquote. Combined with the natural list indent it results
in an overly large left margin.
2025-01-31 12:23:29 -05:00
Nikita Nemkin
718043b540 Help: Convert some literal blocks into tables and lists
Also, ensure that header-less tables have a top border in cmake.css.
2025-01-31 12:23:29 -05:00
Brad King
3e64c6a56e Merge topic 'msvc-runtime-checks'
2b2344b412 MSVC: Add abstraction for runtime checks
49dcd1ce5d Help: Fix MSVC_DEBUG_INFORMATION_FORMAT description of example
2f8e643d9d CMP0141: Fix documentation copied from CMP0091

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Alex <leha-bot@yandex.ru>
Merge-request: !10214
2025-01-30 08:48:01 -05:00
Nikita Nemkin
9890cfc4ec Help: More syntax highlighting for literal blocks
Covers almost all blocks containing actual code, except:

* Parsed-literal blocks can't be highlighted, including many command
  summaries and substitution-heavy docs like find_... commands.
  This is a Sphinx limitation.

* Code with errors, like CMP0049, DEPLOYMENT_ADDITIONAL_FILES,
  DEPLOYMENT_REMOTE_DIRECTORY, @PACKAGE_INIT@ substitution in the
  tutorial, bracket arguments/comments in cmake-language.7 and
  cmake-developer.7.

* FindQt4 module, which needs reformatting.
2025-01-29 16:48:53 -05:00
AJIOB
2b2344b412 MSVC: Add abstraction for runtime checks
Replace our hard-coded default for `/RTC1` with a first-class
abstraction to select runtime checks from an enumeration of logical
names.  Add a `MSVC_RUNTIME_CHECKS` target property and corresponding
`CMAKE_MSVC_RUNTIME_CHECKS` variable.

Removing the old default flag requires a policy because existing
projects may rely on string processing to edit them and choose
runtime checks under the old behavior.  Add policy CMP0184 to
provide compatibility.

Fixes: #26614
2025-01-29 13:07:41 -05:00
Brad King
d6a7a83700 Merge topic 'fix-typos-found-by-pygrep-hooks'
bc4c71627a Help: Fix typos found by the `rst-backticks` hook
c833629508 Help: Fix typos found by the `rst-directive-colons` hook

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10237
2025-01-28 08:35:19 -05:00
Alex Turbov
d2752135cb codespell: Fix typos found by version 2.4 2025-01-27 10:55:58 -05:00
Alex Turbov
bc4c71627a Help: Fix typos found by the rst-backticks hook
The corresponding `pre-commit` configuration is coming in the
separate MR.

Signed-off-by: Alex Turbov <i.zaufi@gmail.com>
2025-01-27 01:43:26 +04:00