Commit Graph

125 Commits

Author SHA1 Message Date
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
Brad King
fc96d99c3e Features: Record initializer list support for Intel 14 and above
Features recorded by commit v3.6.0-rc1~120^2~5 (Features: Record
standards and features for Intel C++ on UNIX, 2016-04-28) for the Intel
compiler left out initializer list support because our test case in
`Tests/CompileFeatures/cxx_generalized_initializers.cpp` caused an
internal compiler error.  It turns out this is because the Intel
compiler asserts the `initializer_list` constructor signatures to verify
that they match its own `<initializer_list>` header.  It was our dummy
implementation used to test the language feature without any headers
that caused the ICE.  Revise it to use a constructor signature accepted
by the Intel compiler.

Fixes: #17829
2018-03-16 07:47:42 -04:00
Brad King
972f7caad3 Tests: Make CompileFeatures C dialect check consistent with impl
`Modules/CMakeCCompilerId.c.in` will report the C dialect as 11 whenever
`__STDC_VERSION__` indicates *at least* C 11.  Make the test consistent
with this.  We already do this for the C++ case.

Fixes: #17740
2018-02-21 14:39:09 -05:00
Daniel Pfeifer
2b4c32c95f clang-format: format all code as Cpp11 2017-08-30 11:07:05 -04:00
Brad King
4f7d9eef51 Features: Fix COMPILE_FEATURES genex for C++ 14 and 17 features
When `CXX_STANDARD` is not at least 14 or 17, features enabled by the
compiler for those standards should not be reported as existing by the
`COMPILE_FEATURES` genex.  Fix the implementation and add a test.
2017-08-08 13:28:38 -04:00
Brad King
131c721f54 MSVC: Add flags for C++ language standards
Visual Studio 2015 Update 3 introduced the notion of language standard
levels to MSVC.  The language standard level is defined in `_MSVC_LANG`
instead of `__cplusplus`.  It also added support for the `-std:c++14`
and `-std:c++latest` flags, although the compiler defaults to its C++14
mode anyway.  Visual Studio 2017 Update 3 will introduce support for the
`-std:c++17` flag.

Fixes: #16482
2017-07-17 10:48:43 -04:00
Chuck Atkins
e556f1b909 CompileFeatures: Makes tests work with meta-feature only 2017-05-29 13:51:45 -04:00
Brad King
5d13fe2822 Features: Record features for SunPro C 5.13 and 5.14 2017-05-11 15:59:48 -04:00
Brad King
d5f39a56a4 clang-format.bash: Use Git attributes to mark files for formatting 2017-02-22 16:59:26 -05:00
Rolf Eike Beer
1679fecb74 CompileFeatures Test: make sure the target "CompileFeatures" is always defined
Everything in there guards against unsupported compilers already, so no need to
skip the whole file if no features are defined. This in turn allows to have a
simpler fallback in case there is no C++ auto_type feature available.
2017-01-30 19:19:44 +01:00
Rolf Eike Beer
ef47272b07 Tests: use cxx_auto_type only if actually available
The presence of CMAKE_CXX_COMPILE_FEATURES doesn't mean cxx_auto_type is always
available.
2017-01-25 21:00:30 +01:00
Brad King
ae1a6815b6 Features: Add infrastructure for C++ 17 language standard
Issue: #16468
2016-12-02 11:22:46 -05:00
Brad King
1f8480312e Features: Suppress c_static_assert test coverage on Intel <= 15
It works on some pre-15.0.2 versions but not others.
2016-11-10 15:29:25 -05:00
Brad King
6d5fb0e0d0 Features: Test feature propagation with language standard meta-feature
The `cxx_static_assert` feature may be available in C++ 98 mode of some
compilers or not available at all in others.  Intstead of using an
individual feature to test propagation of a feature requiring C++ 11,
use the `std_cxx_11` meta-feature that has exactly this meaning.
2016-11-02 10:01:23 -04:00
Brad King
b0996a3fa2 Features: Add meta-features requesting awareness of a particular standard
A common use case of `target_compile_features` is simply to specify that
the compiler should be run in a mode that is aware of e.g. C++11.  Some
projects simply specify a particular C++11-only feature to request this.
Provide a first-class way to do this by naming features after the
corresponding language standard.  Record them as always available in the
corresponding standard level so that requesting them always ensures that
standard (or higher) is used.
2016-11-02 10:00:28 -04:00
Alex Wang
68e7250a9f Features: Fix cxx_right_angle_brackets compiler feature test
The clang-format pass in commit v3.6.0-rc1~54^2~1 (Revise C++ coding
style using clang-format, 2016-05-16) changed the template right angle
brackets from `>>` to `> >`, which defeats the purpose of this test.
Change it back and exclude this content from formatting.
2016-10-25 13:38:12 -04:00
Kitware Robot
d9fd2f5402 Revise C++ coding style using clang-format
Run the `Utilities/Scripts/clang-format.bash` script to update
all our C++ code to a new style defined by `.clang-format`.
Use `clang-format` version 3.8.

* 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.
2016-05-16 16:05:19 -04:00
Brad King
18df6a9a78 Tests: Protect unicode literals from clang-format Cpp03 formatting
Since CMake is written in C++98 any clang-format configuration must
set `Standard` to `Cpp03` so that `A<A<int> >` is not rewritten as
`A<A<int>>`.  However, this will cause `U"foo"` to be rewritten as
`U "foo"`.  Add markup to turn clang-format off in the one place
that the latter case occurs so that we do not need a separate
`.clang-format` config file for it.

Inspired-by: Daniel Pfeifer <daniel@pfeifer-mail.de>
2016-05-11 10:37:45 -04:00
Robert Maynard
36f32ede8d Features: Record standards and features for Intel C on UNIX
Record features for Intel C 12.1 and above.  Skip this for now on
Windows (where Intel C simulates MSVC).
2016-04-28 09:16:35 -04:00
Levi Morrison
be910f00b5 Features: Record standards and features for Intel C++ on UNIX
Skip this for now on Windows (where Intel C++ simulates MSVC).
2016-04-28 09:15:25 -04:00
Brad King
c2d590c957 Features: Update MSVC features for VS 2015 RTM
VS 2015 RTM completed support for constexpr and attribute features.
Update our feature table and test accordingly.
2015-07-21 12:56:47 -04:00
Brad King
ecb1d5b47a Features: VS 2013 Update 3 supports initializer lists (#15494)
VS 2013 originally claimed to support initializer lists but a bug was
found in which it generated bad code silently.  For this reason we
previously considered support to not be present.  However, Update 3 adds
a hard error on cases that previously generated bad code, so it is now
safe to use initializer lists with VS 2013 Update 3 or greater.  At
worst a compiler error will be issued in the cases that do not work, but
that is no different from any other compiler-specific workaround a
project code may need.
2015-04-06 10:06:26 -04:00
Brad King
827309af76 Tests: Fix CompileFeatures cxx_generalized_initializers example
The only reason this failed to compile on VS 2013 was because the
compiler uses different initializer_list constructor argument types than
our dummy implementation.  The standard does not specify the non-default
constructor argument types for initializer_list.  Use a template to
match any two-arg constructor a compiler might select (e.g. begin/end or
begin/len).  Use #error to preserve the error on VS 2013.
2015-04-06 10:05:37 -04:00
Stephen Kelly
fb3487a997 Features: Fix C90 feature detection.
This bug caused c_function_prototypes to not be recorded at configure
time when compiling with -std=gnu99 or similar. In the case of feature
recording, that was not a problem, because the logic in
CMakeDetermineCompileFeatures.cmake currently assumes that a feature
present for an earlier standard is present for a later standard.

However, the detection strings are also used in WriteCompilerDetectionHeader,
so the feature macro has been defined to '0' when using a later language
dialect.

Fix that by not checking the existence of the __STDC_VERSION__ macro at
all when detecting C90 features.
2015-02-04 18:38:21 -05:00
Robert Maynard
d3489bdb0b Features: Record for MSVC 2010-2015
Also, in WCDH add MSVC Compatibility for cxx_align{of,as}.

Co-Author: Stephen Kelly <steveire@gmail.com>
Co-Author: Brad King <brad.king@kitware.com>
2015-01-30 09:57:33 -05:00
Brad King
3228fc5049 Features: Define meaning for no language standard default
Define an empty string in CMAKE_<LANG>_STANDARD_DEFAULT to mean that
the toolchain has no notion of lanuage standard levels.  In this case
the <LANG>_STANDARD[_REQUIRED] properties will have no effect.

Update the RunCMake.CompileFeatures test to exclude the
LinkImplementationFeatureCycle test when there is no standard default.
It can never fail because no use of specific features will adjust the
CXX_STANDARD level required for any target since the standard levels
have no meaning in this case.
2015-01-29 15:01:40 -05:00
Brad King
c1f5d6e6f5 Merge topic 'test-features-enforce-expectation'
67e76e82 Features: Fix test to reject missing expectation definitions
3046be77 Features: Emit a test failure if 'override' is present but not expected
2015-01-27 11:22:12 -05:00
Brad King
67e76e82df Features: Fix test to reject missing expectation definitions
Whenever feature support is added to a compiler, the CompileFeatures
test needs to be updated to set expected availability of features.
Add #error directives to ensure the test fails if expectations are
not set.

Suggested-by: Stephen Kelly <steveire@gmail.com>
2015-01-26 14:41:33 -05:00
Stephen Kelly
3046be7784 Features: Emit a test failure if 'override' is present but not expected 2015-01-26 14:41:33 -05:00
Brad King
9f559a2608 Merge topic 'GNU-4.4-compile-features'
374a66b5 Features: Blacklist raw string literals test for GNU 4.4
2015-01-23 10:50:22 -05:00
Brad King
be2a74dbcb Merge topic 'GNU-4.4-compile-features'
965a50dc Features: Fix GNU 4.4 and 4.5 C standard level flags
7f4154a4 Features: Fix CompileFeatures non-feature tests for space in path
f40c19b5 Features: Fix CompileFeatures test for C non-features
2015-01-22 09:50:36 -05:00
Brad King
374a66b58c Features: Blacklist raw string literals test for GNU 4.4
RedHat gcc 4.4.7-11 supports raw string literals, so simply blacklist
the test for its rejection.
2015-01-22 09:39:35 -05:00
Brad King
7f4154a4aa Features: Fix CompileFeatures non-feature tests for space in path
Fix the <lang>_non_features try_compile calls to work correctly when
there is a space in the path.  Otherwise they all fail due to the space
instead of the lack of a feature.
2015-01-21 15:42:08 -05:00
Brad King
f40c19b543 Features: Fix CompileFeatures test for C non-features
Add a "feature_test.c" file corresponding to "feature_test.cpp" but for
the C language.  This source will be needed by C_non_features entries.
2015-01-21 15:40:47 -05:00
Brad King
813ace90e4 Merge topic 'GNU-4.4-compile-features'
004e1540 Features: Record for GNU 4.4.
2a5ca650 Features: Wrap failure-test in UNIX condition.
1ae2c6b2 Features: Blacklist cxx_constexpr test for GNU 4.5.
c66e3317 Features: Use a more-common feature in cycle-test.
c43a6dc5 Features: Update comment in test to match the code.
78259135 Features: Test presence of cxx_auto_type with genex.
7b9fc88b Features: Remove outdated comment.
2015-01-19 13:55:31 -05:00
Stephen Kelly
1ae2c6b2c9 Features: Blacklist cxx_constexpr test for GNU 4.5. 2015-01-18 14:46:55 +01:00
Stephen Kelly
782591350c Features: Test presence of cxx_auto_type with genex.
The purpose of that test is to cover the case where the genex
reports '1', and the feature is chosen to be present on all/most
supported compilers.  GNU 4.4 does not support cxx_nullptr.
2015-01-17 16:07:53 +01:00
Stephen Kelly
bcb04783f7 Features: Record for SolarisStudio 12.4.
It has similar C++11 capabilities compared to GCC 4.8.
2015-01-17 14:48:28 +01:00