Commit Graph

279 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
fb1bd1d330 CMP0065: Remove support for OLD behavior 2025-01-22 10:40:55 -05:00
Brad King
cbe7fc4b81 CMP0056: Remove support for OLD behavior 2025-01-21 09:44:05 -05:00
Tim Blechmann
339c2b886a cmSystemTools: Add RandomNumber method that avoid re-seeding from OS
When profiling Qt builds on macos, about 2.2% of a `cmake` invocation
was spent reading from `/dev/urandom`.  Use a (thread)local rng to
mitigate this cost, particularly in `cmGeneratedFileStreamBase::Open`.
2025-01-09 11:17:20 -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
35350c419d Add support of "LINKER:" prefix for CMAKE_<TYPE>_LINKER_FLAGS variable
The following variables now support the LINKER: prefix:
* CMAKE_<TYPE>_LINKER_FLAGS
* CMAKE_<TYPE>_LINKER_FLAGS_<CONFIG>

Fixes: #26171
2024-11-04 17:07:58 +01:00
Craig Scott
4cb5bb014d
try_compile: Propagating top level includes into whole-project calls
Fixes: #24151
2024-05-30 19:01:03 +10:00
Brad King
899af83755 Merge topic 'linker-vars-propagate-try_compile'
98cc86e265 try_compile(): Include languages with _ or - when passing linker vars

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !9361
2024-03-24 14:33:31 -04:00
Craig Scott
98cc86e265
try_compile(): Include languages with _ or - when passing linker vars
Fixes: #25809
2024-03-22 21:35:51 +11: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
Brad King
d101cb07ec Merge topic 'cmFileCopier-error-loss'
a820877d03 errors: avoid constructing a stream before getting the last error
5cf7018af6 cmFileCopier: remember error statuses and get their strings
0639a32d3a cmFileTimes: return status codes from APIs

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !9023
2023-12-05 09:23:49 -05:00
Ben Boeckel
a820877d03 errors: avoid constructing a stream before getting the last error
Constructing a stream may involve operations that change the global
error state. Avoid the streams by using `cmStrCat` instead.
2023-12-01 22:58:05 -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
Brad King
dd78592ba1 Merge topic 'try_compile-alias-targets'
8f9f371668 try_compile: Add support for using ALIAS targets
9f8aa94192 Add missing `OUTPUT` in ExportImport test

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !8877
2023-10-17 10:22:54 -04:00
Brad King
c672e51bd3 Merge topic 'try_compile-linker-language'
0f37000304 try_{compile,run}: add LINKER_LANGUAGE option
dc0dbffb0f Tests: Remove redundant policy setting from RunCMake.try_{compile,run} cases

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !8871
2023-10-17 10:18:56 -04:00
Cristian Le
8f9f371668 try_compile: Add support for using ALIAS targets
Fixes: #25337
Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
2023-10-16 20:22:23 +02:00
scivision
0f37000304 try_{compile,run}: add LINKER_LANGUAGE option
Fixes: #25326
2023-10-16 11:30:17 -04: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
Brad King
fd81024e80 cxxmodules: Honor CMAKE_CXX_SCAN_FOR_MODULES in try_compile
Under CMP0155's NEW behavior, projects that explicitly enable C++20
support with `set(CMAKE_CXX_STANDARD 20)` may also explicitly
disable scanning with `set(CMAKE_CXX_SCAN_FOR_MODULES OFF)`.
We already propagate `CMAKE_CXX_STANDARD` into `try_compile` test
projects, so propagate `CMAKE_CXX_SCAN_FOR_MODULES` too.

Fixes: #25313
2023-10-10 11:25:21 -04:00
Ben Boeckel
437280b127 cxxmodules: scan C++ sources for imports by default
Existing projects are not using C++ modules in their sources,
so introduce policy CMP0155 to enable scanning by default.
2023-10-02 10:17:31 -04:00
Ben Boeckel
0c07f39006 cmExperimental: remove the flag for C++ modules
All the major compilers now have scheduled releases with support for
scanning, so remove the experimental gate.

Fixes: #18355
2023-10-02 10:17:31 -04:00
Brad King
e43918b4ca HIP: Fix linking mixed-lang binary with CXX compiler and Makefile generators
Following commit 6377a43814 (CUDA: Support response files with nvcc,
2022-06-01, v3.25.0-rc1~636^2), while determining the compiler ABI, do
not use response files, so that we can extract implicit link flags.

Fixes: #25272
2023-09-25 16:06:36 -04:00
Brad King
127b6fa06b HIP: Add CMAKE_HIP_PLATFORM variable to specify GPU platform
For now, require the value to be `amd`, since that is the only
platform we currently support.
2023-09-21 15:34:37 -04:00
Ben Boeckel
deb1c3cbd5 cmCoreTryCompile: forward module-related binutils variables 2023-07-31 11:59:50 -04:00
Ben Boeckel
b768d293c5 cmCoreTryCompile: use the source type context for source files
Also add a test to `RunCMake/CXXModules` to test `try_compile` with C++
modules.

Fixes: #25097
2023-07-31 11:59:47 -04:00
Ben Boeckel
c9ca5f6326 cmCoreTryCompile: parse SOURCES_TYPE argument
This will serve to add context for the source listing in order to
properly mark sources as `FILE_SET TYPE CXX_MODULES` in the generated
code.
2023-07-31 11:37:47 -04:00
Ben Boeckel
07551f35de cmCoreTryCompile: use target_sources for try_compile targets
In order to support using C++ module sources in `try_compile`,
`target_sources` will be required. To prepare, always use the command.
2023-07-31 11:37:47 -04:00
Ben Boeckel
aad9033b56 cmExperimental: support forwarding associated variables to try_compile
Other variables may be needed to make experimental features actually
work. List them with the experimental flag.
2023-07-31 11:37:47 -04:00
Ben Boeckel
f6cf433256 cmExperimental: only forward C++ module support to non-ABI checks
ABI checks never use modules, so don't forward the experimental status
through.
2023-07-31 11:37:47 -04:00
Ben Boeckel
1a538ae07c cmExperimental: use an enum for whether to forward to try_compile 2023-07-31 11:37:47 -04:00
Brad King
241ee252ce IWYU: Update for Debian 12 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 12.
2023-07-28 09:14:08 -04:00
Ben Boeckel
884c477545 cmCoreTryCompile: combine strings where possible 2023-07-19 16:31:31 -04:00
Ben Boeckel
b8fd1cc8d9 cmCoreTryCompile: use single characters where possible 2023-07-19 16:30:27 -04:00
Ben Boeckel
0b74471d62 cmCoreTryCompile: use cmStrCat where possible 2023-07-19 16:30:27 -04:00
Kyle Edwards
d84681d8f0 try_compile(): Pass down CMAKE_EXPERIMENTAL_* feature flags 2023-07-17 16:53:52 -04:00
Marc Chevrier
241304190f CMake code rely on cmList class for CMake lists management (part. 2) 2023-04-29 09:54:31 +02:00
Marc Chevrier
e08ba229ee CMake code rely on cmList class for CMake lists management (part. 1) 2023-04-24 10:41:10 +02:00
Marc Chevrier
ede33f30cf Apple: Handle generation and comsuption of text-based stubs (.tbd files)
Fixes: #24123
2023-03-01 12:23:28 +01:00
Brad King
5252c88569 try_compile: Record propagated CMake variables in configure log
These provide more detailed information about how the test project was
configured.

Issue: #23200
2023-02-01 09:32:42 -05:00
Brad King
9ee57226bc clang-format: Add comments to suppress some formatting
Preserve manually-formatted blocks.
2023-01-18 16:19:27 -05:00
Brad King
d4bf7d80c6 try_compile: Add a NO_LOG option to skip recording in the configure log 2023-01-16 17:16:12 -05:00
Brad King
9d9e8450a8 try_compile: Add optional LOG_DESCRIPTION to record in configure log
Issue: #23200
2023-01-16 16:58:50 -05:00
Brad King
65ed5c2ca8 try_compile: Report underlying error when COPY_FILE fails 2023-01-16 16:58:49 -05:00
Craig Scott
ba981bb2ed TryCompileCode(): Prevent warning on return value
Some newer compilers warn in situations where the returned local
variable could be movable, but a C++11 defect meant older compilers
may still return a copy when a type conversion is involved. Adding
the suggested std::move prevents that warning on that compiler, but
creates a new warning on others. Constructing the actual return type
explicitly with the suggested std::move on the constructor argument
keeps both sets of compilers happy.
2022-12-30 10:42:55 +11:00
Matthew Woehlke
048a02d5bb ConfigureLog: Log try_compile and try_run checks
Add configure log events for `try_compile` and `try_run` results.

Issue: #23200
2022-12-16 10:12:25 -05:00
Brad King
fdda4095a3 cmCoreTryCompile: Return more semantic information from compile step
Update the `TryCompileCode` signature to allow callers to distinguish
between administrative failures and a compilation failure.  Return
results in a structure to which more information can be added later.
2022-12-14 11:42:29 -05:00
Brad King
80fc564dd7 try_compile: Restore COPY_FILE with CMAKE_TRY_COMPILE_CONFIGURATION
Since commit 0c141b0393 (try_compile: Record output location instead of
reverse computing it, 2022-08-31, v3.25.0-rc1~154^2) we always look for
the "Debug" configuration's output binary from the test project.
Restore looking for the `CMAKE_TRY_COMPILE_CONFIGURATION`.

Fixes: #24180
2022-11-22 11:26:28 -05:00
Brad King
177c56e3fa Merge topic 'try_compile-CMP0128' into release-3.25
50e90e2828 try_compile: Honor CMP0128 setting in test project

Acked-by: Kitware Robot <kwrobot@kitware.com>
Reviewed-by: Raul Tambre <raul@tambre.ee>
Merge-request: !7803
2022-10-19 09:57:08 -04:00