Commit Graph

294 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
Evan Wilde
e7062a79bd Xcode: Remove compiler id dependency on xctest
Previously the compiler identification project would implicitly generate
unit-tests that depend on XCTest when building for iOS, visionOS, and tvOS.

Fixes: #26600
2025-02-07 11:30:05 -05:00
Nikita Nemkin
2c3df0237d Modules: Use math() for hex to decimal conversion
math() can parse hex numbers prefixed with "0x" since 3.13.
2025-02-03 15:04:57 +05:00
Peter Kokot
9f2efc3270
Remove optional arguments from else() and end*() commands
This adds a brief explanation of the optional condition in the `else()`
and removes all legacy usages of `else()` and `end*()` commands.
2025-01-28 03:01:23 +01:00
Brad King
1ebfd7ac81 Merge topic 'gcc-import-std'
2a0ca6a26d ci: add jobs to test GCC 15-to-be with `import std`
469175c2e6 Experimental: recycle the `import std` UUID
a980dab9b1 gcc: support `import std`
2791b7564b Tests/RunCMake: handle C++26 support where needed

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !10023
2025-01-10 09:04:38 -05:00
Ben Boeckel
a980dab9b1 gcc: support import std 2025-01-08 16:32:14 -05:00
Robert Maynard
52d1b4ad05
CompilerId: Console error output has first try last
This ensures that a user after providing custom flags
will first see that attempt. Previously the compiler attempt with the user flags could have been lost due to
console log buffer / scrolling support
2025-01-03 11:27:26 -05:00
David Tenty
a6f2e9eded IBMClang: Express compiler information as a Clang variant
De-duplicate IBMClang compiler information by detecting the base clang
version and following the same logic as we do for any other clang of
that version.  This helps maintain support for new IBMClang features
inherited from new base Clang versions.

We already use this approach for other Clang variants, like CrayClang
and FujitsuClang.
2024-12-04 14:01:52 -05:00
Brad King
b49b03a62e Xcode: Use ad-hoc signing during compiler id for iOS Mac Catalyst
In commit 2785364b7b (iOS: Add support for Mac Catalyst, 2024-07-02,
v3.31.0-rc1~371^2) we forgot to update the conditions to use ad-hoc
signing from commit 89e1113e0c (Xcode: Use ad-hoc signing during
compiler id on macOS, 2022-06-10, v3.22.6~4^2~2).

Fixes: #26376
2024-10-16 15:04:56 -04:00
Brad King
3b4d0df670 NVCC: Detect host compiler id and version
Report them in `CMAKE_<LANG>_HOST_COMPILER_{ID,VERSION}` variables.

Fixes: #20901
2024-09-20 17:48:33 -04:00
Brad King
f94ef8c0c4 Merge topic 'cuda-vs-17.10'
69f26d8156 VS: Fix compiler identification of nvcc with unsupported host compiler

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9546
2024-05-24 10:35:51 -04:00
Brad King
69f26d8156 VS: Fix compiler identification of nvcc with unsupported host compiler
`nvcc` from CUDA < 12.4 does support the MSVC 14.40.17.10 toolset.
Users may specify `CUDAFLAGS=-allow-unsupported-compiler` to bypass the
check.  However, we do not use arbitrary user-specified flags during
compiler identification in the VS generator because escaping them for
the `AdditionalOptions` of the `.vcxproj` file requires non-trivial
logic that we currently only implement in the C++ generator code.
Instead, just always pass `-allow-unsupported-compiler` during CUDA
compiler identification in the VS generator.

Fixes: #26003
2024-05-23 13:22:34 -04:00
Ben Boeckel
ffe74289b3 CMakeDetermineCompilerId: extract C++ standard library impl
This is needed for C++ modules because `import std` support may differ
based on the standard library implementation. Extract the information as
necessary.
2024-04-12 11:46:39 -04:00
Juan Ramos
3cd64287fe Modules: Fix CMP0159 warnings in modules when tracing
Closes: #25829
2024-03-29 13:51:59 -07:00
Brad King
1fc670fb22 Merge topic 'clang-use-arg1'
7008fc234b CMakeDetermineCompilerId: use `_ARG1` to query the clang resource dir

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9285
2024-02-27 09:05:13 -05:00
Brad King
9b4bbd26a9 Merge topic 'clang-use-arg1' into release-3.29
7008fc234b CMakeDetermineCompilerId: use `_ARG1` to query the clang resource dir

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9285
2024-02-27 09:05:12 -05:00
Ben Boeckel
7008fc234b CMakeDetermineCompilerId: use _ARG1 to query the clang resource dir
Other core queries do this, so do it here too.
2024-02-26 11:49:17 -05:00
Brad King
c29bc18b10 Merge topic 'cxxmodules-clang-resource-dir'
a3ada1a241 Clang: detect -resource-dir for clang-scan-deps

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9274
2024-02-22 08:24:00 -05:00
Brad King
a4122c89c4 Merge topic 'cxxmodules-clang-resource-dir' into release-3.29
a3ada1a241 Clang: detect -resource-dir for clang-scan-deps

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9274
2024-02-22 08:23:58 -05:00
Ben Boeckel
a3ada1a241 Clang: detect -resource-dir for clang-scan-deps
When cross-compiling, `clang-scan-deps` needs help to find the correct
location of core headers such as `stddef.h`. Always determine this path
and pass it when available.

Fixes: #25590
2024-02-21 08:51:42 -05:00
Alan Phipps
9ba0a54554 TIClang: Add support for TI Clang-based compilers, including tiarmclang
Add TIClang compiler ID and support in compiler modules.  Update
documentation.  Add rudimentary RunCMake test for TIClang to test
basic functionality.

Fixes: #24619
2024-02-09 15:54:40 -05:00
Brad King
f610541523 Merge topic 'clang-cl-showIncludes' into release-3.29
0d933fc0d9 Ninja: Update showIncludes prefix detection for clang-cl 18
a88acb0a41 Tests/RunCMake/Ninja: Rename showIncludes case for clang-cl <= 17

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9229
2024-02-08 09:40:52 -05:00
Martin Storsjö
0d933fc0d9 Ninja: Update showIncludes prefix detection for clang-cl 18
Since commit LLVM/Clang commit `5523fefb01c2` ([clang][lex] Use
preferred path separator in includer-relative lookup, 2023-09-08), part
of the upcoming 18.x release, the output format of the showIncludes flag
has changed, where it now prints paths with double backslashes:

    Note: including file: .\\foo.h

Previously, we expected to see the path name in the form "./foo.h".

Extend the regex to match a path name starting with `.\`, in addition to
the existing matched patterns.
2024-02-07 09:38:14 -05:00
Brad King
cd28915260 LLVMFlang: Update MSVC ABI and architecture detection for LLVMFlang 18.0
LLVMFlang 18.0 adds MSVC ABI and architecture macros.  Resolve the
corresponding FIXME left by commit 26bf32cdc6 (LLVMFlang: Add support
for targeting MSVC ABI on Windows, 2023-09-28, v3.28.0-rc1~10^2).

Issue: #24840
2023-12-06 09:42:07 -05:00
Brad King
43d218d970 VS: Add support for using Intel oneAPI Fortran compiler in .vfproj files
Add a `fortran={ifort,ifx}` field to `CMAKE_GENERATOR_TOOLSET` to
specify which Intel Fortran compiler to use.

Fixes: #25427
2023-11-22 10:22:12 -05:00
Brad King
26bf32cdc6 LLVMFlang: Add support for targeting MSVC ABI on Windows
The compiler does not yet support everything needed to integrate well
with the MSVC ABI, in particular for runtime library selection and debug
format selection.  Document them in FIXME comments and leave this
support undocumented by CMake for now.

Fixes: #24840
Inspired-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
2023-10-03 09:15:24 -04:00
Brad King
db09cc188f Merge topic 'vs-props-order'
e4fe26201f VS: Remove duplicate import in compiler id vcxproj

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !8740
2023-08-19 08:40:12 -04:00
Brad King
e4fe26201f VS: Remove duplicate import in compiler id vcxproj
Since commit d3c4c6d630 (VS: Import default C++ props file before
toolset-specific props file, 2023-03-01, v3.27.0-rc1~361^2) we import
`Microsoft.Cpp.Default.props` twice.  Remove the extra import line, and
re-order imports as intended by the original change.
2023-08-18 09:49:25 -04:00
Gregor Jasny
25977e177b apple: add preliminary visionOS support 2023-07-11 20:20:25 +02:00
Brad King
a59b35ba33 Merge topic 'msvc-wine-showIncludes'
fb3c4715cd Ninja: Restore detection of msvc-wine showIncludes prefix

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: huangqinjin <huangqinjin@gmail.com>
Merge-request: !8479
2023-05-16 10:40:09 -04:00
Brad King
fb3c4715cd Ninja: Restore detection of msvc-wine showIncludes prefix
Since commit 8f82e755f3 (Ninja: Fix detection of MSVC showIncludes
prefix in Italian, 2023-01-26, v3.26.0-rc1~20^2) our regex no longer
matches the output from `msvc-wine`, which uses forward slashes:

    Note: including file: /path/to/foo.h

`cl /showIncludes` under Wine prints paths of the form `Z:\path\to\file`,
but the `msvc-wine` wrapper converts them to the form `/path/to/file` so
that native Ninja can be used.  Update our regex to match the prefix
followed by a path with a leading forward slash.

Fixes: #24908
2023-05-15 15:34:55 -04:00
Michael Karcher
850ee280e0 VS/Android: Set API level explicitly during compiler identification
VS2022 defaults to API 31 in 64-bit builds.  This breaks if you combine
VS2022 with an older Android NDK.
2023-04-25 13:47:17 -04:00
Michael Karcher
e78abf94e3 VS/Android: Use ApplicationTypeRevision 3.0 in VS2022
Visual Studio 17 (Marketing name: Visual Studio 2022) still ships with
"3.0" as most recent Variant of the Android application type.
Use this revision.
2023-04-25 13:45:37 -04:00
Brad King
2cdb0bae28 Merge topic 'clang-cl-showIncludes'
843fc607de Ninja: Restore detection of clang-cl showIncludes prefix
3346570ae9 Tests: Comment RunCMake.Ninja ShowIncludes sample input languages

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !8344
2023-03-21 08:57:35 -04:00
YR Chen
843fc607de Ninja: Restore detection of clang-cl showIncludes prefix
Since commit 8f82e755f3 (Ninja: Fix detection of MSVC showIncludes
prefix in Italian, 2023-01-26, v3.26.0-rc1~20^2) our regex no longer
matches the output from `clang-cl`, which uses a relative path, forward
slashes, and is always in English [1]:

    Note: including file: ./foo.h

Update the regex to match that too.

[1] https://github.com/llvm/llvm-project/blob/llvmorg-16.0.0/clang/lib/Frontend/HeaderIncludeGen.cpp#L102

Co-authored-by: Brad King <brad.king@kitware.com>
2023-03-20 10:08:25 -04:00
Matthew Voss
d3c4c6d630 VS: Import default C++ props file before toolset-specific props file
This avoids overwriting toolset-specific settings like `VCRedistDir`
with default settings.

Fixes: #22420
2023-03-07 14:41:32 -05:00
Russell Greene
7201bc072c CompilerId: Fix handling of CMAKE_<LANG>_FLAGS with quotes
Use `separate_arguments` to correctly parse arguments with quotes.

Fixes: #24385
2023-02-03 10:39:22 -05:00
Brad King
8f82e755f3 Ninja: Fix detection of MSVC showIncludes prefix in Italian
The prefix does not have two colons.  Update our regex.

Fixes: #24357
2023-01-28 07:16:58 -05:00
Brad King
a9d97492fd Ninja: Record showIncludes detection in configure log
Also avoid running the detection multiple times.
2023-01-27 10:55:37 -05:00
Brad King
f6ed2585e5 Modules: Record system inspection steps in the configure log
Replace old-style `file(APPEND .../CMake{Output,Error}.log)` logging
with calls to `message(CONFIGURE_LOG)` to record the steps in the
`CMakeConfigureLog.yaml` configure log instead.

Issue: #23200
2023-01-18 17:59:10 -05:00
Brad King
a80465bcad GHS: Drop debugging message from log 2023-01-18 16:41:00 -05:00
Brad King
24ccc8c3c9 CompilerId: Restore logging of failed identifications
Changes in commit 9c5bd7fe3a (CompilerId: Output errors from all
attempts at detection, 2022-08-16, v3.25.0-rc1~290^2) accidentally
stopped logging failed compiler identification build output.
2023-01-18 16:41:00 -05:00
Russell Greene
e4fcdfa301 Set CMAKE_<LANG>_COMPILER_FRONTEND_VARIANT on single-variant compilers
The `GNU` and `MSVC` compilers obviously use their own front-end
command-line style.  Also set this for `AppleClang`.

Fixes: #24232
2023-01-11 14:50:40 -05:00
Brad King
2e5af30ce0 Ninja: Match showIncludes dependencies using console output code page
Generalize the fix from commit 37a279f8d1 (Ninja: Write msvc_deps_prefix
as UTF-8 when console codepage is UTF-8, 2020-07-31, v3.19.0-rc1~349^2).
`cl /showIncludes` output is encoded using the console output code page,
so this is the byte sequence that Ninja must use to match its lines.

Fixes: #24068
2022-10-30 08:29:55 -04:00
Robert Maynard
9c5bd7fe3a CompilerId: Output errors from all attempts at detection
Instead of printing the output of the last attempt, print
the output of all attempts. This shows users that CMake isn't ignoring any provided flags ( LANG_FLAGS ).
2022-08-16 11:59:46 -04:00
Brad King
aafa598e24 Merge topic 'xcode-14'
627c08e28b Tests: Teach RunCMake to ignore Xcode DVTSDK warnings
ab40020b17 Xcode: Suppress "Run Script" build phase warning during compiler id
89e1113e0c Xcode: Use ad-hoc signing during compiler id on macOS

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7350
2022-06-11 05:39:11 -04:00
Brad King
89e1113e0c Xcode: Use ad-hoc signing during compiler id on macOS
Xcode 14 no longer accepts an empty signing identity for macOS.
However, Xcode in general does not accept an ad-hoc signing
identity for iOS.  Switch based on the target platform.

Fixes: #23609
2022-06-10 14:22:40 -04:00
Brad King
c267ed205a CUDA: Defer architecture testing to the compiler testing step
Verifying the architectures during compiler identification is redundant,
and requires a lot more up-front information than we should need.
It also causes unsupported architectures to break the compiler id and
version detection, so the resulting output from CMake does not report
the compiler version, which is useful information to know why the
specified architectures are not supported.

The "detecting compiler ABI info" and "check for working compiler" steps
already pass `CMAKE_CUDA_ARCHITECTURES` into their test projects.
Therefore we can just drop the earlier architecture testing.  Bad
architectures will be reported as a not-working compiler, and the
output will include the compiler's error message.

This reverts the approach from:

* commit 19cc5bc296 (CUDA: Throw error if user-specified architectures
                     don't work, 2020-05-26, v3.18.0-rc1~79^2)
* commit 650c1029a0 (CUDA: Detect non-working user-specified architectures
                     on NVCC, 2020-05-28, v3.18.0-rc1~51^2)
* commit 01428c5560 (CUDA: Fail fast if CMAKE_CUDA_ARCHITECTURES
                     doesn't work during detection,
                     2020-08-29, v3.19.0-rc1~241^2).

Their goal was in part to avoid waiting until the test for working
compiler to detect unsupported architectures.  However, experience has
shown that failing earlier is more trouble than it's worth.

Fixes: #23161
Issue: #20756
2022-04-25 15:01:36 -04:00
Chris Wright
e9eabb0dcd ADSP: Configure compiler in compiler module 2022-04-04 16:56:47 +01:00
Brad King
d1b48bfabd CUDA: Add support for CUDA_ARCHITECTURES=native
CUDA 11.6 added the `nvcc -arch=native` flag to automatically compile
for the host GPUs' architectures.  Add support for specifying this
special `native` value in `CMAKE_CUDA_ARCHITECTURES` and
`CUDA_ARCHITECTURES`.  During the compiler ABI detection step,
detect the native architectures so we can pass them explicitly
when using Clang or older versions of nvcc.

Fixes: #22375
2022-03-10 09:27:29 -05:00