162 Commits

Author SHA1 Message Date
Brad King
c299fd8266 Tests/CompileFeatures: Cover hip_std_## meta-features 2024-05-28 14:36:50 -04:00
Brad King
fb0990ef04 Tests/CompileFeatures: Cover cuda_std_## meta-features 2024-04-19 08:39:15 -04:00
Brad King
011f3d1dd3 Tests/CompileFeatures: Fix c_std_23 case with Clang < 14
Generalize the `__STDC_VERSION__` exception previously added for
AppleClang < 14 to also cover LLVM/Clang < 14.  Although the two
vendors do not follow the same version scheme, the major versions
happen to match in this case.
2024-04-19 08:39:15 -04:00
Brad King
1f40604421 Tests/CompileFeatures: Cover CUDA default standard level 2024-04-18 08:30:38 -04:00
Raul Tambre
2038f2c2b1 C++26: Support detection as the default standard
This was missed in commit f808d8afb9 (CMake: Support upcoming C++26
language level, 2022-08-19, v3.25.0-rc1~218^2).
2024-04-16 15:34:57 -04:00
Raul Tambre
f21dbf8f26 C++26: Fix C++/CUDA/HIP compile feature support
In commit f808d8afb9 (CMake: Support upcoming C++26 language level,
2022-08-19, v3.25.0-rc1~218^2) we forgot some necessary scaffolding.

Fixes: #25819
2024-04-09 11:38:59 +03:00
Brad King
c7cbe57e1f Clang: Fix detection of C++26 when targeting MSVC ABI
`_MSVC_LANG` may not be defined higher than C++20, but `__cplusplus` is.
2024-04-09 11:38:51 +03:00
Brad King
31acc90abe ci: Record expected C and CXX language standard support
Explicitly enable standard levels in the `CompileFeatures` test that are
expected to work in each job regardless of whether compiler inspection
detects support.
2024-04-05 07:38:58 -04:00
Brad King
c37e279014 Tests/CompileFeatures: Cover c_std_## and cxx_std_## meta-features 2024-04-05 07:38:58 -04:00
Brad King
58cd9ee03c Tests/CompileFeatures: Factor out headers to compute C and C++ standard levels 2024-04-05 07:38:56 -04:00
Brad King
80a5a86514 GNU: Fix detection of C++ 11 mode in GCC 4.{4,5,6}
These versions of the compiler have experimental C++11 support and so do
not define `__cplusplus` correctly, but do define a feature macro we can
use to distinguish this mode.
2024-04-05 07:38:14 -04:00
Brad King
c9cc3dc646 PGI: Fix detection of C++ 14/17 modes
The PGI compiler is based on EDG.  Share conditions with Intel Classic.
2024-04-05 07:38:06 -04:00
Brad King
7f05d472a2 NVHPC: Fix detection of C++ 20 mode on NVHPC < 22.7
This compiler does not always define `__cplusplus` correctly, but does
define a feature macro that we can use to distinguish this mode.
2024-04-05 07:37:03 -04:00
Brad King
3587579f34 XL/XLClang: Fix detection of C++ 14 mode on Linux
This compiler does not always define `__cplusplus` correctly, but does
define a feature macro that we can use to distinguish this mode.
2024-04-04 17:56:31 -04:00
Brad King
863cde8c19 Intel: Fix detection of C++ 14/17 modes on Linux/macOS
The Intel Classic C++ compiler is based on EDG.  It does not always
define `__cplusplus` correctly, but does define feature macros that we
can use to distinguish these modes.
2024-04-04 17:56:02 -04:00
Brad King
1e774a86d3 Intel: Fix detection of C++ 17/20 modes on Windows
The Intel Classic C++ compiler for Windows does not always define
`_MSVC_LANG` correctly, but does define feature macros that we can use
to distinguish these modes.
2024-04-04 16:48:46 -04:00
Brad King
b9d4db7098 CompilerId: Clarify C and C++ standard level detection
Use named constants.  Regularize comparison patterns.
2024-04-04 15:13:17 -04:00
Brad King
264dcae5e4 Tests: Fix clang -Wstrict-prototypes warnings 2023-10-26 09:20:45 -04:00
David Lindauer
531b4fe643 OrangeC: Add support for OrangeC compiler
Add compiler information modules.  Update the test suite.

Fixes: #25032
Co-authored-by: Brad King <brad.king@kitware.com>
2023-09-25 12:27:29 -04:00
Brad King
a5fd03a53d Tests: Teach CompileFeatures to tolerate __STDC_VERSION__ on Intel Classic 2023-05-01 15:51:21 -04:00
Kitware Robot
33abef7416 Revise C++ coding style using clang-format-15
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`.  Use `clang-format` version 15.

* 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.

Fixes: #24315
2023-01-18 16:20:47 -05:00
Brad King
48639aa8fc clang-format.bash: Use generic clang-format attribute
Specify the clang-format version in the attribute value instead of its
name.

Issue: #24315
2023-01-18 11:48:49 -05:00
Brad King
914571a042 Place language standard flags just after CMAKE_<LANG>_FLAGS
Previously we added the language standard flag near the end of all
options, even after those added by `add_compile_options` and friends.
However, on some compilers such as MSVC, the `-std` flag may reset
defaults for flags that precede it on the command line.  Move the
language standard flag to before all other flags that CMake adds for
other abstractions, and before those added by `add_compile_options`.

`CMAKE_<LANG>_FLAGS` should still precede the language flags though,
because they are meant to be treated as language-wide modifications to
the compiler defaults, similar to `$CC $CFLAGS`.

Fixes: #23860
Fixes: #24170
2022-11-18 11:44:52 -05:00
Robert Maynard
f808d8afb9 CMake: Support upcoming C++26 language level 2022-08-31 13:46:18 -04:00
Aaron Liu
6da99e671c IBMClang: Add support for IBM Open XL C/C++
Fixes: #22929
2022-01-27 09:38:01 -05:00
makise-homura
e5d9fce03f LCC: Add dedicated support for MCST LCC compiler
Divert LCC compiler as a new one, instead of treating it as GNU.

Since old times, Elbrus C/C++/Fortran Compiler (LCC) by MCST has been
passing checks for GNU compilers, so it has been identified as GNU.
Now, with intent of seriously upstreaming its support, it has been
added as a separate LCC compiler, and its version displays not a
supported GCC version, but LCC version itself (e.g. LCC 1.25.19 instead
of GNU 7.3.0).

This commit adds its support for detection, and also converts basically
every check like 'is this compiler GNU?' to 'is this compiler GNU or
LCC?'. The only places where this check is untouched, is where it
regards other platforms where LCC is unavailable (primarily non-Linux),
and where it REALLY differs from GNU compiler.

Note: this transition may break software that are already ported to
Elbrus, but hardly relies that LCC will be detected as GNU; still such
software is not known.
2021-10-15 05:05:19 +03:00
nic-kaczinsky
ae2c24b0ba Tests: Fix warning clang-analyzer-cplusplus.NewDeleteLeaks
Fix the warning: `potential leak of memory pointed to by "vp"`.
2021-04-16 11:49:51 -04:00
Yuichiro Utsumi
a237450948 Tests: Update for the FujitsuClang compiler 2021-03-31 09:14:45 -04:00
Chuck Atkins
a55feff69c Tests: Update for the Fujitsu compiler 2021-03-31 09:14:38 -04:00
Raul Tambre
dcd599757f C23 support 2021-02-25 18:22:10 +02:00
Raul Tambre
93b7d3d292 C17 support
Implements #17755.
2021-02-25 18:22:10 +02:00
Brad King
01b1e9c40d Tests: Update CompileFeatures test for IntelLLVM
We do not have granular features for this compiler.
2021-01-28 09:07:01 -05:00
Brad King
549eedfe85 Tests: Fix CMP0115 warnings in CompileFeatures test
Pass source file extensions explicitly.
2021-01-28 09:05:34 -05:00
Tin Huynh
4de28ba4e6 Tests: Update tests for NVHPC compiler
Treat it just like PGI.
2021-01-27 09:53:02 -05:00
Raul Tambre
9f3c70a333 CUDA, CXX, OBJCXX: C++23 support with Clang 12
Clang 12 landed initial support for C++23 language mode flag -std={c|gnu}++2b
in commit 6627a3c2873fdf7ccba1a1573371079be48b36e8.
2020-12-08 18:43:59 +02:00
Brad King
3fb146cb11 Tests: Update CompileFeatures test for Intel 19 with VS 2015
Blacklist `cxx_relaxed_constexpr` for this case because the compiler
does not advertise the support in this mode but compiles our example.
2019-10-10 13:14:42 -04:00
Brad King
847e8bc98c Intel: Fix default C++ dialect detection on Windows
For the Intel Compiler for Windows we have some subtle preprocessor
checks in compiler feature detection to detect C++11 and C++14 modes.
Use these when detecting the default C++ dialect too.
2019-10-10 13:14:42 -04:00
Robert Maynard
1ebb0d79fe CompileFeatures: Relax cxx_relaxed_constexpr compiler requirements
This in effect means that cxx_relaxed_constexpr is now supported
by MSVC and Intel 18.0-18.04.
2019-05-13 13:11:32 -04:00
Brad King
66f3f11af5 SunPro: Record support for C++14 features by SunPro 5.{14,15}
SunPro 5.15 supports `-std=c++14` and several C++14 features.

SunPro 5.14 accepts `-std=c++14` but does not update its definition of
`__cplusplus` or any other macro to distinguish it from `-std=c++11`,
so we need to blacklist a couple features that do work but that we
cannot report for that version.  We can still support `cxx_std_14`.

Co-Author: Robert Maynard <robert.maynard@kitware.com>
2019-04-19 09:14:00 -04:00
Robert Maynard
b0f46c48f6 CompileFeatures: Now able to presume full language level support
Previously compilers that only supported the meta-level flags
would not have any of the granular features listed. Now we
presume that they have full support and enable all the features.

Update granular feature tests to skip the actual compilation
checks for the presumed features.
2019-04-09 08:44:56 -04:00
Brad King
0d641fcfad Tests: Remove outdated portion of CompileFeatures genex test
The genex part of the test verifies that `$<COMPILE_FEATURES:...>`
evaluates as expected.  It does not need to actually try using code with
the associated features, as that is tested separately.
2019-04-09 08:44:56 -04:00
Zsolt Parragi
c7213ca870 Features: Do not use a lower-than-default standard for requested features
`AddRequiredTargetC(xx)` feature didn't take the default compiler
standard into account, which possibly resulted in the use of an older
standard when some features requested it.

Fixes: #18686
2019-02-26 14:35:55 -05:00
Kitware Robot
d7204e649e Revise C++ coding style using clang-format-6.0
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`.  Use `clang-format` version 6.0.

* 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.
2018-06-01 09:53:42 -04:00
Brad King
523c443d13 clang-format.bash: update to clang-format-6.0
Update `.clang-format` with configuration to make the 6.0 format as
close as possible to what 3.8 produced before.  Then revise the style:

* Indent preprocessor directives (a feature new since 3.8)
* Add a newline and indentation before inheritance `:` and `,`

Rename the Git attribute identifying the format to include the
clang-format version number: `format.clang-format-6.0`.  This will aid
external infrastructure in knowing what version of the tool to run.
2018-06-01 09:52:02 -04:00
Brad King
4edf0d68ee Tests: Simplify CompileFeatures expectation logic
Rather than repeating compiler version checks for feature availability,
generate genex expectations using the detect list of features.  We
already separately verify that the list of features is correct.
2018-04-06 14:45:58 -04:00
Brad King
1b6ec4b9e3 Merge topic 'features-c++20'
8570dc7f64 Help: Update compiler versions in cmake-compile-features.7.rst
874d3d2948 Help: Add release note for C++ 20 support
7f295b1bd3 Features: Activate C++ 20 support for Clang 5.0+
71cb8ce3a1 Features: Activate C++ 20 support for GNU 8.0+
8f146c4508 Features: Activate C++ 20 support for MSVC 19.12.25835+
7fe580a362 Features: Add infrastructure for C++ 20 language standard
1b328e09a3 Features: Use -std=c++17 for C++ 17 on Clang 5.0+
0bc3e5788a Features: Use -std=c++17 for C++ 17 on GNU 8.0+

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1892
2018-04-02 10:01:23 -04:00
Brad King
a53cf69022 Features: Record C features for MSVC
The MSVC C compiler has no notion of C language standards or flags.
Tell CMake to assume that all language standards are available.
Record available C language features depending on the version of
the compiler.

Fixes: #17858
2018-03-29 10:40:13 -04:00
Brad King
e62dfeccb1 Features: Do not assume c_restrict support in CompileFeatures test
Define `EXPECT_C_RESTRICT` separately for each compiler.
2018-03-28 10:54:43 -04:00
Brad King
c22cdf78d7 Features: Fix CompileFeatures test checks for C
Compare the HAVE_ and EXPECT_ macros as we do for CXX.
2018-03-28 10:54:41 -04:00
Brad King
7fe580a362 Features: Add infrastructure for C++ 20 language standard
Issue: #17849
2018-03-27 07:40:54 -04:00