Commit Graph

2656 Commits

Author SHA1 Message Date
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
Brad King
26460454b7 Merge topic 'patch-CheckCompilerFlag'
ac67631b02 Check{,C,CXX,Fortran,OBJC,OBJCXX}CompilerFlag: Update documentation

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10840
2025-05-30 09:35:17 -04:00
Brad King
1c8fa92921 Merge topic 'windows-module-def-per-lang'
8b710d8264 Linker: Generate per-language module -DEF: flags on Windows

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Markus Mützel <markus.muetzel@gmx.de>
Merge-request: !10836
2025-05-29 10:11:13 -04:00
Peter Kokot
ac67631b02 Check{,C,CXX,Fortran,OBJC,OBJCXX}CompilerFlag: Update documentation
- Added intro code blocks showing how to include these modules.
- Used word "command" instead of "macro".
- Added examples sections.
- Updated and synced descriptions of commands and arguments.
- Added a rubric title for variables that affect the checks.
- Listed CMAKE_TRY_COMPILE_TARGET_TYPE variable in the rubric together
  with CMAKE_REQUIRED_* variables.
- Added link to CheckCompilerFlag module in the target_compile_options()
  docs.
- Used lowercase style for check_fortran_compiler_flag() command.
- Added a link to `$<COMPILE_LANGUAGE:languages>` generator expression
  so it can be linked from other pages (See commit
  2e37a20f02 for more info on the initial
  style used).
- Fixed the GENEX_NOTE inclusion (starting with line after the 2nd line)
  where part of the sentence was rendered in the output.
2025-05-29 00:16:39 +02:00
Brad King
8b710d8264 Linker: Generate per-language module -DEF: flags on Windows
With IntelLLVM on Windows, we link using the compiler driver.
With MSVC on Windows, we invoke the linker directly.  If we
use both in a single build tree, for separate languages,
the value of `CMAKE_LINK_DEF_FILE_FLAG` conflicts.  Add a
per-language `CMAKE_<LANG>_LINK_DEF_FILE_FLAG` variable to
avoid the conflict.  Preserve the language-agnostic variable
for compatibility with projects that reference it.

Fixes: #26005
2025-05-28 13:48:26 -04: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
Brad King
2bd60d2d2f Merge topic 'swift-module-nested-structure'
1711e86d6c Swift: Generate nested swift modules in build dir
b36175abdb Swift: Detect module triple from compiler

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10664
2025-05-23 08:23:28 -04: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
fc9e9d1196 Merge topic 'automoc-specific-include-dirs'
39677f4cc6 AUTOMOC: Add option to specify moc include directories explicitly

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Acked-by: Osyotr <zhenchik35026@gmail.com>
Merge-request: !10640
2025-05-21 08:46:35 -04:00
Brad King
bb10fb3990 Merge topic 'patch-CheckSymbolExists'
58e8999c28 CheckSymbolExists, CheckCXXSymbolExists: Update documentation

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10804
2025-05-21 08:33:36 -04:00
Brad King
6aa604ef10 StdIo: Honor NO_COLOR environment variable
This convention is documented by https://bixense.com/clicolors/

Closes: #26458
2025-05-20 11:57:29 -04:00
Brad King
edb80c068b Merge topic 'find-package-event-providers'
3d60b0ba1d configure-log: fill in dependency provider information

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !10785
2025-05-20 09:13:36 -04:00
David Worley
39677f4cc6 AUTOMOC: Add option to specify moc include directories explicitly
Add a `AUTOMOC_INCLUDE_DIRECTORIES` target property and a corresponding
`CMAKE_AUTOMOC_INCLUDE_DIRECTORIES` variable to initialize it.
This is useful for targets that do not need moc to search include
directories from all dependencies.

Closes: #26414
2025-05-19 21:07:48 -04:00
Peter Kokot
58e8999c28 CheckSymbolExists, CheckCXXSymbolExists: Update documentation
- Added intro code blocks showing how to include these modules.
- Added section titles.
- Used "command" instead of "macro".
- Indented command-related descriptions according to the command
  section indentation level.
- Added the "See Also" sections.
- Synced descriptions between the modules.
2025-05-20 01:23:02 +02:00
Brad King
b91a376350 Merge topic 'configure-log-find-foo-fixes'
3ac505f79d cmFindCommon: log search path variables
e98381af21 cmFindBase: skip writing `names` and `*_directories` when empty

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !10772
2025-05-19 08:31:17 -04:00
Brad King
db4e27eb64 Merge topic 'per-target-license-info'
df3e246bc1 export: Import/export target property for license

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !10424
2025-05-19 08:29:12 -04:00
Ben Boeckel
3ac505f79d cmFindCommon: log search path variables
No pruning of variables which are not relevant is performed as it would
involve duplication of determining which paths to manage.
2025-05-15 12:24:58 +02:00
Ben Boeckel
3d60b0ba1d configure-log: fill in dependency provider information
This uses the special "path" of `dependency_provider::…` to indicate the
provider in use.
2025-05-14 22:12:46 +02:00
xndcn
ad1d9507ba Help: Fix JOIN generator expression syntax example
Fix syntax of the JOIN generator expression example,
from `$<JOIN,list,glue>` to `$<JOIN:list,glue>`.
2025-05-14 09:31:26 -04:00
Daniel Tierney
df3e246bc1 export: Import/export target property for license
Add import/export support and documentation for the SPDX_LICENSE
target property. A target's license can be specified by setting
this property to an SPDX license expression. CMake and CPS-format
export files generated with `export()` or `install()` will
retain the license information. CMake also imports the license
property for imported targets.

Closes: #26706
2025-05-13 17:01:20 -04:00
Ben Boeckel
8df9819839 find_package: generate find_package-v1 configure log events
Since `find_package` is far more complex than other `find_*` commands,
it gets its own event.

Closes: #24833
2025-05-09 16:46:43 +02:00
Brad King
805a40b668 Optionally exclude implicit link libraries via environment
CMake detects libraries that the compiler driver implicitly passes to
the linker, and stores them in `CMAKE_<LANG>_IMPLICIT_LINK_LIBRARIES`
for use in constructing mixed-language link lines.  Some compiler driver
flags add implicitly linked libraries that should not be used during
mixed-language linking because they are handled by similar flags passed
to the other language's compiler driver.  Add an environment variable
that users can set to avoid undesired implicit link libraries in such
scenarios.

Follow the pattern from commit 023de565d3 (Optionally exclude implicit
link directories via environment, 2023-05-25, v3.27.0-rc1~54^2).

Fixes: #26911
2025-05-05 12:12:44 -04: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
74e677f62b Merge topic 'clang-libstdcpp-support'
5750fcd7b4 ci: enable `import_std23` module compilation with clang
52e2785018 experimental/CXXModules: recycle the UUID
28333c4516 Clang/CXXImportStd: support `-stdlib=libstdc++`

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10727
2025-05-01 08:40:49 -04:00
Brad King
3076dc9c5b Merge topic 'cxxmodules-gcc-15'
425ee2dd88 Help/cmake-cxxmodules: note GCC 15 support

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10726
2025-05-01 08:29:06 -04:00
Ben Boeckel
28333c4516 Clang/CXXImportStd: support -stdlib=libstdc++
Fedora 42 ships `clang` with `libstdc++` as the default. Detect and
support `import std;` in this configuration.
2025-04-30 13:47:27 +02:00
Ben Boeckel
425ee2dd88 Help/cmake-cxxmodules: note GCC 15 support 2025-04-30 13:45:39 +02: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
Brad King
e94ace226b Merge topic 'configure-log-find-v1'
a3f273b657 cmFindBase: Create `find-v1` configure log events
58b5d41a4f cmFindBase: Track initial state with an `enum`

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !10621
2025-04-29 10:54:10 -04:00
Ben Boeckel
a3f273b657 cmFindBase: Create find-v1 configure log events
Record `find_` command events in the configure log, except
`find_package` as it is far more complicated (and will have its own
event kind).

Note that testing only generates the events of interest, there is no
verification. Also note that testing that the "found" to "notfound"
transition causes an event is not testable because a truthy value in the
variable skips any kind of verification or other logic beyond
normalization.

Co-Authored-by: Ryan Krattiger <ryan.krattiger@kitware.com>
See: #24833
2025-04-28 13:55:36 +02:00
Vito Gamberini
0138df29dc project: add COMPAT_VERSION keyword
Fixes: #26893
2025-04-25 13:42:11 -04:00
Brad King
3cc9b88eba Merge topic 'fileapi-reply-on-failure'
0cc962665b fileapi: Generate partial reply when buildsystem generation fails
09aa968ed0 cmFileAPI: Add BuildReplyEntry wrapper around AddReplyIndexObject
5e0a644ee8 Tests/RunCMake/FileAPI: Explicitly specify expected reply index prefix
0a0bd69f4b Help: Polish cmake-file-api(7) manual

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !10652
2025-04-17 09:59:20 -04:00
Brad King
7be87256a6 Merge topic 'patch-FindSDL'
905d461431 Find_SDL*: Update documentation

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10657
2025-04-16 09:10:58 -04:00
Peter Kokot
905d461431 Find_SDL*: Update documentation
This updates the following modules:
- FindSDL
- FindSDL_gfx
- FindSDL_image
- FindSDL_mixer
- FindSDL_net
- FindSDL_sound
- FindSDL_ttf

Changes:
- Synced modules documentation.
- Added examples sections.
- Used the ``<PackageName>_FOUND`` variables. The uppercased
  ``<PACKAGENAME>_FOUND`` variables are also set to the same value as of
  CMake 3.3.
- Added notes regarding the CMake package configuration files
  provided by upstream distributions with separate imported targets.
- Find modules index sorted alphabetically for FindSDL* modules.
2025-04-15 14:23:12 +02:00
Brad King
0cc962665b fileapi: Generate partial reply when buildsystem generation fails
In particular, the `configureLog` reply is useful for IDEs to read
`CMakeFiles/CMakeConfigureLog.yaml` when configuration fails.

Fixes: #26621
2025-04-14 10:42:03 -04:00
Brad King
0a0bd69f4b Help: Polish cmake-file-api(7) manual
Re-order some bullets to list the success case first.
Also remove a repeated word.
2025-04-14 09:33:38 -04: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
Felipe Torrezan
c7d2a17253 IAR: Add support for C-STAT static analysis
The IAR platform offers an integrated static analysis tool named
IAR C-STAT.

Closes: #26844
2025-04-09 12:01:02 -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
Brad King
2afcbe9a81 Merge topic 'patch-cmake-developer-docs'
4af847a1cd Help: Refine the Foo_VERSION_STRING explanation

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10568
2025-04-01 12:57:21 -04:00
Brad King
029415fc68 Merge topic 'unity-relative-paths'
f706d8064b Help: Clarify wording of UNITY_BUILD_RELOCATABLE path alternatives
20412690fb Help: Add 4.0 release note for UNITY_BUILD_RELOCATABLE
89cea1c642 Help: Document CMAKE_UNITY_BUILD_RELOCATABLE variable

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10570
2025-04-01 12:54:36 -04:00
Brad King
89cea1c642 Help: Document CMAKE_UNITY_BUILD_RELOCATABLE variable
In commit 84996a65aa (Unity: Add option to use relative paths for unity
files, 2024-10-15, v4.0.0-rc1~637^2) we added support for this variable
to initialize the `UNITY_BUILD_RELOCATABLE` target property, but forgot
to document it.

Issue: #26352
2025-03-31 19:31:00 -04:00
Peter Kokot
4af847a1cd Help: Refine the Foo_VERSION_STRING explanation
Changes:

- The Foo_VERSION_STRING variable is a legacy variable name and should
  be set in find modules only if the existing module is replacing some
  of its previous version. Meaning new modules/code shouldn't introduce
  such variable from scratch.
- Reworded some sentences to remove "you" making the documentation more
  neutral and less direct.
2025-04-01 00:55:59 +02:00
Craig Scott
cf9f4177a2 Merge topic 'doc-cpack-configs'
d289d720cb Help: Use consistent plural form for CPack configurations

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10546
2025-03-30 05:55:58 -04:00
Brad King
e0b64aad53 Merge topic 'remove-FindCABLE'
2b8b17106c FindCABLE: Add policy to remove this module
3c2ed4bbc6 FindGCCXML: Move documentation to list of deprecated modules

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !10540
2025-03-28 09:16:34 -04:00
Brad King
883ba45df8 Merge topic 'patch-CMakeFindPackageMode'
e9b86f5618 CMakeFindPackageMode: Move documentation to --find-package option

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10537
2025-03-28 09:12:32 -04:00
Craig Scott
d289d720cb Help: Use consistent plural form for CPack configurations 2025-03-28 15:46:12 +11:00
Peter Kokot
e9b86f5618 CMakeFindPackageMode: Move documentation to --find-package option
- This moves the CMakeFindPackageMode internal module documentation to
  the --find-package option as this module itself cannot be used by the
  project.
- Additionally, some links added.
- The `QUIET` variable renamed in documentation to `SILENT` to be
  effective according to the current code.
2025-03-27 15:29:36 +01: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