Commit Graph

47 Commits

Author SHA1 Message Date
Brad King
c283aafe62 CMP0057: Remove support for OLD behavior 2025-01-22 10:40:53 -05:00
Brad King
f4aa34daa7 Tests/RunCMake: Update cmake_minimum_required versions to 3.10
For policy-specific tests, use the version before the policy was
introduced.  Otherwise, use 3.10 where possible.
2024-10-03 11:52:22 -04:00
Brad King
9ced5932cf Tests/RunCMake/CompileFeatures: Avoid intermittent failures on AIX
Apply the fix from commit b3245f33ef (Tests/RunCMake/install: Avoid
intermittent failures on AIX, 2024-05-10) to `RunCMake.CompileFeatures`
too.
2024-05-20 20:11:19 -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
Brad King
1edb2b409a Merge topic 'ci-xcode-15.3'
682767e8a5 Merge branch 'backport-3.28-ci-xcode-15.3'
e572986231 LinkerId: Update detection of linker tool for Xcode 15.3
8a6d05aa9d gitlab-ci: update macOS jobs to use Xcode 15.3
7bf893bc30 Tests: Update RunCMake.CheckCompilerFlag for Xcode 15.3
7f5f0ab4b3 Tests: Update RunCMake.CompileFeatures for Xcode 15.3

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9333
2024-03-13 10:51:13 -04:00
Brad King
7f5f0ab4b3 Tests: Update RunCMake.CompileFeatures for Xcode 15.3
Xcode no longer puts an extra backslash in its `-std=` flags.
2024-03-12 09:29:29 -04:00
Brad King
9c5e981e60 Add deprecation warnings for policies CMP0128 and below
The OLD behaviors of all policies are deprecated, but only by
documentation.  Add an explicit deprecation diagnostic for policies
introduced in CMake 3.22 and below to encourage projects to port
away from setting policies to OLD.
2024-02-06 17:07:09 -05:00
Brad King
04b0d5c862 codespell: Fix typos 2023-05-22 16:51:15 -04:00
Brad King
1edf138506 Tests/RunCMake: Update cmake_minimum_required versions
For policy-specific tests, use the version before the policy was
introduced.  Otherwise, use 3.5 where possible.

Also, remove `cmake_minimum_required()` and `project()` calls from
individual cases where they are handled by `CMakeLists.txt`.
2023-02-11 06:24:22 -05:00
Raul Tambre
d5014741c9 Tests/CompileFeatures: Fix CMP0128OldSameStandard with default OFF
With CMP0128 OLD compiler extensions are enabled by default regardless of the
compiler's default.
Fix the test to always check for the extension flag as it was intended to.

Fixes: 4a0485be7f (cmStandardLevelResolver: Avoid
unnecessary flags, fix unset level logic, 2021-04-29)
2022-06-04 18:40:21 +03:00
Brad King
d5e3b1ca1e Merge topic 'cmp0128_cuda'
ee1396e29e CMP0128: Add flag in OLD mode even when standard matches the default
b2c25de8e0 CMP0128: Avoid test code duplication
3a089cd256 CMP0128: Prefix test names with mode
e13dd52535 XL: Detect default extensions mode for legacy compiler

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6890
2022-01-24 12:37:52 -05:00
Raul Tambre
ee1396e29e CMP0128: Add flag in OLD mode even when standard matches the default
Commit 4a0485be (cmStandardLevelResolver: Avoid unnecessary flags, fix unset
level logic, 2021-04-29) unintentionally changed the behavior by modifying the
code to match a pre-existing comment. The resulting behavior change however
matches the intentions of CMP0128, so we simply need to guard it.

Fixes #23122.
2022-01-23 23:10:28 +02:00
Raul Tambre
b2c25de8e0 CMP0128: Avoid test code duplication 2022-01-23 23:10:28 +02:00
Raul Tambre
3a089cd256 CMP0128: Prefix test names with mode
Makes clear that these tests are for the NEW behaviour.
2022-01-23 23:10:28 +02:00
Robert Maynard
ec1e40af1a cmStandardLevelResolver: Better error message on unsupported language level
Fixes #23079
2022-01-11 16:03:57 -05:00
Raul Tambre
e47dfce75d CMP0128: Enable/disable extensions if standard same as default
This was intended to be part of the initial MR (!6177), but accidentally went
missing when debugging nightly failures on less common systems. Noticed during
!6711 review as the comment about this behaviour didn't match the code.

Documentation for CMP0128 is updated to remove a false case and note the two
cases related to this.

Fixes #22224.
2021-11-11 21:55:04 +02:00
Raul Tambre
4a0485be7f cmStandardLevelResolver: Avoid unnecessary flags, fix unset level logic
The changes are part of CMP0128.

When the standard level is unset:
* Flags are added if extension mode doesn't match the compiler's default.
  Previously logic only worked if LANG_EXTENSIONS was ON. Fixes #22224.
* The full flag is used. Previously CMAKE_LANG_EXTENSION_COMPILE_OPTION was
  used. This was only supported for IAR.

Otherwise:
* Avoid adding flags if not necessary per the detected compiler defaults.
* Fixed check for when the requested standard is older. It now matches the
  nearby comments.

I reworded the fallback comment as its logic was a bit difficult to wrap my
head around.
2021-09-29 22:28:40 +03:00
Raul Tambre
29e2b85171 Tests: Simplify RunCMake.CompileFeatures introspection 2021-09-28 21:24:53 +03:00
Chuck Atkins
e556f1b909 CompileFeatures: Makes tests work with meta-feature only 2017-05-29 13:51:45 -04:00
Brad King
df252db15a Features: Test cycle diagnostic 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 cyclic requirement of a feature requiring
C++ 11, use the `std_cxx_11` meta-feature that has exactly this meaning.
2016-11-02 10:01:24 -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
Stephen Kelly
7235334a2f Project: Determine default language dialect for the compiler.
Use the __cplusplus and __STDC_VERSION__ macros to automatically
determine the default dialect for the compiler while determining its
id and version.
2015-09-18 10:00:21 -04:00
Brad King
17b4423c45 Merge topic 'fix-crash-on-bad-LANG_STANDARD'
00d66557 Diagnose invalid <LANG>_STANDARD value instead of crashing (#15426)
2015-03-02 08:36:24 -05:00
Brad King
00d66557d4 Diagnose invalid <LANG>_STANDARD value instead of crashing (#15426) 2015-02-28 12:14:42 -05:00
Stephen Kelly
1c3918ff02 RunCMake: Remove unneeded files.
The default expectation of RunCMake tests is empty content, so there
is no need to specify it.
2015-02-09 19:15:04 +01: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
539c5c252e Tests: Shorten paths in RunCMake.CompileFeatures
Shorten the NotAFeature_OriginDebug_target_compile_features case name to
avoid creating really long paths that fail with some tools on Windows.
2015-01-26 08:30:57 -05:00
Stephen Kelly
c66e331749 Features: Use a more-common feature in cycle-test.
We require that the $<$<COMPILE_FEATURES:cxx_feature>:empty2> generates
a '1' when CXX11 is enabled.  GNU 4.4 does not support cxx_nullptr, but
does support cxx_auto_type.
2015-01-18 14:46:45 +01:00
Stephen Kelly
c43a6dc5ec Features: Update comment in test to match the code.
After commit f13a2eb1 (Features: Adjust the RunCMake test to use
more-common features., 2015-01-15).
2015-01-18 14:46:45 +01:00
Stephen Kelly
f13a2eb118 Features: Adjust the RunCMake test to use more-common features. 2015-01-16 00:11:01 +01:00
Brad King
4ce110bbba Tests: Revert workaround for COMPILE_FEATURES genex bug
The second hunk of commit 07d1f6fc (Features: Properly evaluate if the
compiler supports cxx_final, 2014-12-31) was a workaround for a bug in
the COMPILE_FEATURES generator expression that caused it never to return
0.  Revert the workaround so we can fix the bug instead.
2015-01-14 13:41:45 -05:00
Brad King
0b7e7e277c Revert topic 'feature_record_msvc'
Revert commits:

 2d738ce3 Help: Add notes for topic 'feature_record_msvc'
 f73718c9 Features: Enable writing of MSVC compiler feature header.
 64c30bdc Features: Record for MSVC C++ 2015 and MSVC C 2010-2015.
 225c0ef8 Features: Record for MSVC 2010-2013.

This topic was merged to master prematurely, so remove it.
2015-01-14 13:35:58 -05:00
Robert Maynard
f73718c9b8 Features: Enable writing of MSVC compiler feature header.
Notes:
VS2015 and above are the only MSVC versions to support cxx_final, so remove
usages from the tests, and instead only test for cxx_override.

VS2012 and above to conform to cxx_decltype_incomplete_return_types
proposal, but without support for auto return types the dcl.type.simple
example in the proposal doesn't compile.

VS2013 and above to conform to the updated cxx_contextual_conversions proposal,
but VS2010 and above pass the test.

Compilers such as MSVC have no explicit flags to enable C++11 mode,
it just is always on. So only run the link tests with compilers that require
a flag to specify the language version.
2015-01-11 11:32:36 -05:00
Robert Maynard
07d1f6fca1 Features: Properly evaluate if the compiler supports cxx_final.
Previously we expanded HAVE_FINAL to determine what the copied_file number
would be, but when we don't have cxx_final than HAVE_FINAL is not defined.
What we really want is to use expected_result.
2015-01-11 16:47:58 +01:00
Brad King
b341799e53 Tests: Fix RunCMake.CompileFeatures test NonValidTarget2 case
Mark the generated source file with the GENERATED property explicitly
since it is not marked automatically as the output of any custom
command.  Mark both the 0 and 1 variants so it works no matter the
outcome of the generator expression.
2014-12-22 10:36:35 -05:00
Stephen Kelly
60a981ea8e Features: Enable compiler extensions by default.
Compilers enable their extensions by default, and disabling them
implicitly can lead to results which are surprising or non-obvious
to debug.

 http://public.kitware.com/pipermail/cmake-developers/2014-May/010575.html
 http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/10214
 https://www.mail-archive.com/cmake-developers@cmake.org/msg10116.html
 (Compiler feature extensions by default, 29 May 2014)
2014-05-31 12:16:12 +02:00
Stephen Kelly
0dfe395e3c Features: Add COMPILE_FEATURES generator expression.
Allow setting build properties based on the features available
for a target.  The availability of features is determined at
generate-time by evaluating the link implementation.

Ensure that the <LANG>_STANDARD determined while evaluating
COMPILE_FEATURES in the link implementation is not lower than that
provided by the INTERFACE of the link implementation.  This is
similar to handling of transitive properties such as
POSITION_INDEPENDENT_CODE.
2014-05-21 17:22:32 +02:00
Stephen Kelly
e0890d03a4 Features: Extend concept to C language.
Add properties and variables corresponding to CXX equivalents.

Add features for c_function_prototypes (C90), c_restrict (C99),
c_variadic_macros (C99) and c_static_assert (C11). This feature
set can be extended later.

Add a <PREFIX>_RESTRICT symbol define to WriteCompilerDetectionHeader
to conditionally represent the c_restrict feature.
2014-05-15 00:15:18 +02:00
Stephen Kelly
eb638c75cc Tests: Make CompileFeatures feature list lang-specific. 2014-05-10 13:05:46 +02:00
Brad King
3e206022ab Merge topic 'minor-cleanups'
47795421 Fix whitespace in docs.
aa283b6b Features: Fix test for GNU 4.8.1.
bbfd4cd4 Features: Include the language of the compiler in error messages.
2014-05-08 11:27:57 -04:00
Stephen Kelly
bbfd4cd48f Features: Include the language of the compiler in error messages. 2014-05-07 12:36:22 +02:00
Stephen Kelly
205215fb8a cmTarget: Add CXX_STANDARD_REQUIRED to control decay. 2014-05-07 12:17:49 +02:00
Stephen Kelly
8d0b1ccac1 Features: FATAL_ERROR on compilers with no recorded features.
Users of the new target_compile_features command are expected to
check the existence of the CMAKE_CXX_COMPILE_FEATURES variable before
attempting to use it to require features.
2014-04-17 16:20:50 +02:00
Stephen Kelly
8ed59fc207 Add target_compile_features command.
This can be used to set the compiler features required by particular
targets. An error is issued at CMake time if the compiler does not
support the required feature. If a language dialect flag is required
by the features used, that will be added automatically.

Base the target_compile_features command on cmTargetPropCommandBase. This
gives us 'free' handling of IMPORTED, ALIAS, INTERFACE, non-compilable
and missing targets.
2014-04-07 18:11:18 +02:00
Stephen Kelly
5412deded1 cmTarget: Transitively evaluate compiler features.
Extend the interface of the target_compile_features command with
PUBLIC and INTERFACE keywords. Populate the INTERFACE_COMPILER_FEATURES
target property if they are set. Consume the INTERFACE_COMPILER_FEATURES
target property from linked dependent targets to determine the final
required compiler features and the compile flag, if needed.

Use the same pattern of origin-debugging which is used for other
build properties.
2014-04-07 18:11:18 +02:00
Stephen Kelly
baff44345c cmTarget: Allow populating COMPILE_FEATURES using generator expressions.
Delay validation of the content as a feature if it contains a
generator expression. It will be checked again at generate-time
after evaluation.
2014-04-07 18:11:18 +02:00
Stephen Kelly
f97bf4370c Features: Add cxx_auto_type.
Record the availability of this feature for GNU 4.8 on (UNIX AND
NOT APPLE) only.  In the future, availability can be recorded for
earlier GNU, for other platforms and for other compilers. Initially
the affected configurations are as restricted as possible to allow
for easy testing while extending the features vector in only one
dimension.

The error message when using the set_property API directly is not
very good, but follow up commits will provide origin debugging of
the property and a target_compile_features command which will
provide a configure-time backtrace when possible.
2014-04-07 18:11:18 +02:00