Commit Graph

1509 Commits

Author SHA1 Message Date
Kitware Robot
1772622772 LICENSE: Replace references to Copyright.txt with LICENSE.rst
```
git grep -lz 'Copyright.txt or https://cmake.org/licensing ' |
  while IFS= read -r -d $'\0' f ; do
    sed -i '/Copyright.txt or https:\/\/cmake.org\/licensing / {
              s/Copyright.txt/LICENSE.rst/
            }' "$f" ; done
```
2025-03-03 10:43:35 -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
Kitware Robot
0b96ae1f6a Revise C++ coding style using clang-format with "east const"
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`, now with "east const" enforcement.
Use `clang-format` version 18.

* If you reached this commit for a line in `git blame`, re-run the blame
  operation starting at the parent of this commit to see older history
  for the content.

* See the parent commit for instructions to rebase a change across this
  style transition commit.

Issue: #26123
2025-01-23 13:09:50 -05:00
Brad King
10cfc8f538 Merge topic 'extern-domain'
e109307c43 Add support for foreign targets

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !10171
2025-01-22 09:30:49 -05:00
Vito Gamberini
e109307c43
Add support for foreign targets 2025-01-21 15:26:40 -05:00
Brad King
e4fddc8e37 CMP0051: Remove support for OLD behavior 2025-01-20 09:46:54 -05:00
Brad King
9f6011e307 CMP0049: Remove support for OLD behavior 2025-01-19 09:41:03 -05:00
Brad King
ed99370f63 CMP0043: Remove support for OLD behavior
Note that per-source `COMPILE_DEFINITIONS_<CONFIG>` are not covered by
the policy, and are still supported.
2025-01-19 09:41:02 -05:00
Brad King
f8bc8780c1 CMP0026: Remove support for OLD behavior 2025-01-19 09:40:59 -05:00
Brad King
888259c894 CMP0022: Remove support for OLD behavior 2025-01-18 09:51:45 -05:00
Brad King
72e27a4856 Merge topic 'fix-typos-found-by-pre-commit-hooks'
d620d77d26 FindDoxygen: Rename `_Doxygen_dne_header` -> `_Doxygen_do_not_edit_header`
e7ff3cccea PushToAndroidDevice.cmake: Rename `cmake_parse_arguments` prefix
bc8621d999 Fix: A lot of typos in code found by `typos`
b33beb7af5 Help: Fix some typos found by `sphinx-lint`
78e45c2db6 Style: Replace TABs with spaces for indentation in some files
74e0173f66 Tests(NuGet): Fix the test to ignore empty and space-only lines

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10151
2025-01-14 09:44:34 -05:00
Alex Turbov
bc8621d999
Fix: A lot of typos in code found by typos
Yet another great code spellchecker: https://github.com/crate-ci/typos/

(Will be added later as a `pre-commit` hook)
2025-01-12 18:49:34 +04:00
Cristiano Carvalheiro
7d28005244 Xcode: Support for test action 'Build Configuration' scheme property
Also allow scoped property checking on Xcode scheme tests to
 be able to distinguish between launch and test actions build config.
2025-01-09 16:36:33 +00:00
Cristiano Carvalheiro
419cfe30d0 Xcode: Support for 'LLDB Init File' scheme property
Fixes: #24002
2024-12-13 08:31:11 -05:00
Garrett Campbell
9ed178f9d8 Add generator-agnostic DEBUGGER_WORKING_DIRECTORY target property
Generalize the `VS_DEBUGGER_WORKING_DIRECTORY` property.

Issue: #16478
2024-12-09 10:47:10 -05:00
Brad King
5c78623143 AIX: Enable shared library archives by default
This is the preferred convention for shared libraries on AIX.
Add policy CMP0182 to provide compatibility.

Closes: #26372
2024-11-23 15:23:25 -05:00
Brad King
1cd99d288f Merge topic 'aix-archive-shared-libraries-export'
cd6fb63093 AIX: Propagate AIX_SHARED_LIBRARY_ARCHIVE through exports

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !10027
2024-11-23 15:12:51 -05:00
Brad King
cd6fb63093 AIX: Propagate AIX_SHARED_LIBRARY_ARCHIVE through exports
Teach `export()` and `install(EXPORT)` to record this setting on the
imported targets they generate.  Make this property's non-presence
authoritative on imported targets since they represent what was built
elsewhere.
2024-11-21 19:02:00 -05:00
Brad King
659d8bd430 cmPolicies: Remove now-unused REQUIRED_IF_USED and REQUIRED_ALWAYS states 2024-11-13 11:43:07 -05:00
Marc Chevrier
7907c83175 Link step: Add LINK_WARNING_AS_ERROR target property
Add a way to specify, in a portable way, to raise an error for any
warning during the link step. For that purpose, define:
* CMAKE_LINK_WARNING_AS_ERROR variable
* LINK_WARNING_AS_ERROR target property

Fixes: #25343
2024-11-12 15:11:53 +01:00
James Moore
84996a65aa Unity: Add option to use relative paths for unity files
Add a target property that will be read on unity file generation to
attempt to use a relative path to the source file from the CMake Source
Directory or the generated unity file. Additionally add the CMake
Source Directory and the CMake Binary directory to the include path of
the generated unity files.

Closes: #26352
2024-10-15 09:44:18 -07:00
Daniel Pfeifer
58c5f77837 clang-tidy: fix readability-redundant-* warnings 2024-10-11 15:37:21 +02:00
Brad King
7abd3137b7 Linking: Optionally reorder direct dependencies from LINK_LIBRARIES
Traditionally CMake generates link lines by starting with the direct
link dependencies specified by `LINK_LIBRARIES` in their original order
and then appending indirect dependencies that the direct dependencies
do not express.  This gives projects control over ordering among
independent entries, which can be important when intermixing flags
and libraries, or when multiple libraries provide the same symbol.
However, it may also result in inefficient link lines.

Add support for an alternative strategy that can reorder direct link
dependencies to produce more efficient link lines.  This is useful
for projects that cannot easily specify their targets' direct
dependencies in an order that satisfies indirect dependencies.

Add a `CMAKE_LINK_LIBRARIES_STRATEGY` variable and corresponding
`LINK_LIBRARIES_STRATEGY` target property to select a strategy.

Fixes: #26271
2024-09-25 06:48:57 -04:00
Ben Boeckel
dcf9a66ffe cxxmodules: plumb control data for exporting build databases
This includes the target property, its initializing variable, its
initializing environment variable, and updating related docs to mention
the new bits.
2024-08-27 12:37:36 -04:00
Ben Boeckel
c66821b22b cmGeneratorTarget: add the concept of a "family" name
With synthetic targets, a name which is the same between all synthetic
targets which share a base target is warranted.
2024-08-27 11:30:23 -04:00
Aditya Vidyadhar Kamath
d27fe9dfba AIX: Add option to archive shared libraries
Add option `CMAKE_AIX_SHARED_LIBRARY_ARCHIVE`.

There will no versions for the shared objects when this option is used.

Closes: #26033
2024-07-17 11:52:09 -04:00
Juan Ramos
197cb419d1 add_custom_command: Add CODEGEN support
By specifying CODEGEN as an argument to add_custom_command the
custom command will be added to a codegen build target.

The intent is to provide a convenient way for users to get
their generated files without having to build the whole project.

This can be helpful for code analysis tools which can be useful
for IDEs and CI.
2024-07-01 12:02:49 -04:00
Ben Boeckel
7146cf9248 cmTarget: support the CXX_MODULE_STD property 2024-04-11 10:19:44 -04:00
Vitaly Stakhovsky
1a49b439a5 Source: Use cmValue::IsOn and IsOff
Speed up a bit by calling members directly.
2024-03-17 19:05:37 -04:00
Brad King
3a171009e9 Merge topic 'vs-UseDebugLibraries'
b814641444 VS: Add [CMAKE_]VS_USE_DEBUG_LIBRARIES options to control UseDebugLibraries
67de5b7b82 VS: Suppress MSBuild default settings affected by UseDebugLibraries
0ae372daee VS: Factor out common MS tool configuration

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9270
2024-02-20 10:37:32 -05:00
Brad King
5bc5a485fa Merge topic 'cxxmodules-transitive-target-usage'
8b6fc81fc3 cmTarget: copy link libraries from the right properties
d4a517f82a Tests/CXXModules: add a test with transitive targets

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !9265
2024-02-20 10:30:26 -05:00
Brad King
b814641444 VS: Add [CMAKE_]VS_USE_DEBUG_LIBRARIES options to control UseDebugLibraries
This indicates to MSBuild which configurations are considered debug
configurations.  This is useful for reference both by humans and tools.

Issue: #25327
2024-02-19 10:40:41 -05:00
Ben Boeckel
8b6fc81fc3 cmTarget: copy link libraries from the right properties
This fixes transitive dependencies' usage requirements not appearing
when compiling synthetic targets.

See: https://discourse.cmake.org/t/9819
2024-02-19 10:25:29 -05:00
Brad King
73b76563fb Merge topic 'validate_read-only_target_properties'
0cfd8fe8ad cmTarget: Don't allow setting read-only properties

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !9133
2024-01-24 08:39:09 -05:00
Robert Maynard
0cfd8fe8ad
cmTarget: Don't allow setting read-only properties
Ensure that all documented read-only target properties now produce
errors when trying to set.
2024-01-23 08:50:38 -05:00
Orkun Tokdemir
7c39dabdbc Autogen: AUTO*_EXECUTABLE: add support for per-config values
* Per-config values were added to `AUTO*_EXECUTABLE`.
* Dependency order was refactored for `cmake_autogen` and `cmake_autorcc` to avoid unnecessary rebuilds.
* A new parameter was added for `cmake_autogen` and `cmake_autorcc` to specify the config name of the `auto*_executable` to be used.
* Add `AUTOGEN_BETTER_GRAPH_MULTI_CONFIG` target property to change the behavior of the dependency graph.
* The timestamp target is split into three targets for per-config to avoid redundant `mocs_compilation` builds when `AUTOGEN_BETTER_GRAPH_MULTI_CONFIG`	 is ON
* Per-config `DEP_FILE_RULE_NAME` values were added to `AutogenInfo.json` for `Multi-Config` usage.
* Some functions were refactored to avoid code duplication.

This commit reimplements fddd0f0443

Fixes: #20074
2024-01-17 16:02:58 +01:00
Ralf Habacker
1ec0372ed4 add_test: Optionally use a launcher for tests running in-project targets
Add a `CMAKE_TEST_LAUNCHER` variable and corresponding `TEST_LAUNCHER`
target property.

Issue: #23672
2023-12-13 10:20:43 -05:00
Brad King
1f7a653e90 Merge topic 'swift-compilation-mode'
0f80101b73 Tests: Update Swift tests to use CMP0157 NEW behavior
c1d787e473 Swift: Add abstraction for compilation mode
c39384f540 Tests: Simplify RunCMake.Swift conditions to enable use of Swift

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !8918
2023-11-19 11:47:37 -05:00
Evan Wilde
c1d787e473 Swift: Add abstraction for compilation mode
Add a `CMAKE_Swift_COMPILATION_MODE` variable and corresponding
`Swift_COMPILATION_MODE` target property to control the compilation
mode.  Select among `wholemodule`, `singlefile`, and `incremental`.

Add policy CMP0157 to remove the default `-wmo` flags in favor of the
abstract setting.

Issue: #25366
2023-11-17 08:43:21 -05:00
tophoo
7a07887055 Autogen: Add support for response files for moc predef targets
Add support for response files for moc predef targets and make the limit when
to use response files for autogen targets configurable.
2023-11-16 16:29:02 +01:00
Kyle Edwards
c6e6861e63 install(EXPORT): Export find_dependency() calls
Issue: #20511
Co-Authored-by: Brad King <brad.king@kitware.com>
Co-Authored-by: Robert Maynard <rmaynard@nvidia.com>
2023-11-13 11:07:52 -05:00
Marc Chevrier
96a953b1ed Add options to specify linker tool
Offer the capability, through variable `CMAKE_LINKER_TYPE`, as well as
the target property `LINKER_TYPE` to specify which linker must be used.

The implementation of this capability is specified by variables specific
to the language and linker type: `CMAKE_<LANG>_USING_LINKER_<TYPE>`.
Some definitions are provided as part of `CMake`.

For example, to select the `LLVM` linker rather than the standard one,
the type `LLD` should be specified through the variable `CMAKE_LINKER_TYPE`.
And, on `Apple`, `Linux` and some environments on `Windows`, the variable
`CMAKE_<LANG>_USING_LINKER_LLD` has value `-fuse-ld=lld`. And for `Windows`
environments  based on `MSVC`, where the linker is used directly, the tool
`lld-link.exe` will be used rather than `link.exe`.

Fixes: #19174, #24254, #24990
2023-10-13 11:52:35 +02:00
Martin Duffy
ec2ba29ac5 Ninja: Allow compilation before generation of dependencies' private sources
This requires knowing when a generated header is public, which we can
model using file sets.  Add policy CMP0154 to treat generated sources
as private by default in targets with file sets.  Generated public
headers can be specified in public file sets.

Fixes: #24959
Issue: #15555
2023-09-20 10:25:24 -04:00
Ben Boeckel
80d6544398 cxxmodules: generate synthetic targets as an initial pass
We need to be able to construct BMIs that will be usable from the client
modules for the target importing the module, so create BMI-only
compilation rules for `IMPORTED` targets to create these BMIs.
2023-08-17 14:42:53 -04:00
Ben Boeckel
caf5971c8a cmTarget: report that synthetic targets can compile sources 2023-08-17 14:42:53 -04:00
Ben Boeckel
3a8ea5c3a0 cmTarget: rename entry copying method
It will also be used to copy from other targets, not just directories.
2023-08-17 14:42:53 -04:00
Ben Boeckel
1ccf25b049 cmTarget: track and store IMPORTED_CXX_MODULES_ usage properties
While not "usage requirements" directly, when applied to a target that
will eventually have the BMI compile rules attached to them, they need
tracked as such.
2023-08-17 14:42:53 -04:00
Craig Scott
84eae7aeda
OPTIMIZE_DEPENDENCIES: Skip order-only deps for non-linking targets
Fixes: #21517
2023-08-10 09:17:56 +10:00
Ben Boeckel
d718262faa cmTarget: handle HIP_STANDARD like other language standards 2023-07-29 09:35:20 -04:00
Kyle Edwards
7050ac56a1 macOS: Add support for linking against .xcframework folders
Issue: #21752
2023-07-26 17:00:01 -04:00