Commit Graph

255 Commits

Author SHA1 Message Date
Brad King 9042c875dc Merge topic 'fix-C-standard-features'
fb3487a9 Features: Fix C90 feature detection.
6027798a Features: Allow setting standard dialect below the default.
9d767810 Features: Populate CMAKE_<LANG>_STANDARD_DEFAULT only for supported compilers.
72537e44 Features: Add dialect compile flags only if default is known.
82c9d686 AppleClang: Remove redundant UNIX condition.
2015-02-05 09:25:14 -05: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
Stephen Kelly 9d767810e1 Features: Populate CMAKE_<LANG>_STANDARD_DEFAULT only for supported compilers.
If no compiler feature information is known for a given compiler
version, do not set a language standard default either.  The two
settings must be recorded consistently.
2015-02-04 18:29:53 -05:00
Stephen Kelly 82c9d6868b AppleClang: Remove redundant UNIX condition. 2015-02-04 18:28:06 -05:00
Stephen Kelly 68b5b23b3b Features: Update GNU 5.0 C++14 features.
Trunk already has these features and they are listed in the status
page.  Also confirmed manually by running trunk.
2015-01-31 21:16:12 +01: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 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 965a50dcea Features: Fix GNU 4.4 and 4.5 C standard level flags
The C90 flags were only the "89" versions until GNU 4.5.
The C11 flags were not introduced until GNU 4.6.
2015-01-21 15:47:13 -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 004e1540e0 Features: Record for GNU 4.4. 2015-01-18 15:01:15 +01:00
Stephen Kelly 7b9fc88b04 Features: Remove outdated comment. 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
Stephen Kelly b15c008fac Features: Record for GNU 4.6.
Adjust the CompileFeatures genex_test for the expectation of the
OVERRIDE_CONTROL feature group.
2015-01-16 00:11:01 +01:00
Stephen Kelly 938bd94eb0 Features: Test __GXX_EXPERIMENTAL_CXX0X__ macro for GNU < 4.7 compatibility. 2015-01-15 22:13:22 +01:00
Stephen Kelly 462c630b8a Features: Don't test __cplusplus value for CXX98 on GNU.
The macro is defined to 1 for GNU 4.6, and such a test is only
useful for features in language dialects newer than the
default (CXX98 for GNU currently).

Test only that it has a truthy value.
2015-01-15 22:13:22 +01:00
Stephen Kelly 222ec86f7d Features: Test an old value of __STDC_VERSION__ for GNU < 4.7 compatibility. 2015-01-15 22:13:22 +01:00
Stephen Kelly 6e909035af Features: Record C/CXX dialect flags for GNU 4.6.
This release was prior to standardization of C11/CXX11.
2015-01-15 22:13:22 +01:00
Stephen Kelly bfc995cc3b Features: Remove wrong content from else() condition.
As this is not elseif(), the content has no effect.

Rather than changing it to an elseif(), remove the conditional content.
All versions of GNU prior to 5.0 default to C90/89.

Clang-C.cmake has a similar code block which correctly uses
elseif() for setting the default C dialect to C99.  That may have
been updated from a C90 default at some point, so leave the
version condition there in place for now.
2015-01-15 22:13:22 +01:00
Stephen Kelly 1532b9214f Features: Make cxx_noexcept available from GNU 4.6.
As listed in the reference document.
2015-01-15 22:13:22 +01:00
Stephen Kelly a60027a642 Features: Ensure appropriate return value from feature test macros.
GNU-CXX already has complex logic and sets the _result to 0 before
tests which may set it to something else.

Change the other modules to be consistent with that.
2015-01-15 22:13:21 +01:00
Brad King b4263abdea Merge topic 'Xcode-clang-compile-features'
dcd72a74 Help: Add notes for topic 'Xcode-clang-compile-features'
3ad893b5 Features: Record for historical Xcode clang versions.
98965fb1 Features: Record dialect flags for AppleClang 4.0+.
2015-01-15 09:54:08 -05:00
Brad King 101a62aacb Merge topic 'revert-feature_record_msvc'
4ce110bb Tests: Revert workaround for COMPILE_FEATURES genex bug
0b7e7e27 Revert topic 'feature_record_msvc'
2015-01-15 09:53:47 -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
Stephen Kelly 00f66a0451 Record compile features for GNU on Apple.
Tested with GNU 4.8 binary (bottle) from homebrew, and assumed to work
with the others.
2015-01-11 18:34:25 +01:00
Brad King 775fb2e0b0 Merge topic 'feature_record_msvc'
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.
2015-01-11 12:00:24 -05:00
Stephen Kelly 3ad893b5c2 Features: Record for historical Xcode clang versions. 2015-01-11 16:52:27 +01:00
Stephen Kelly 98965fb12d Features: Record dialect flags for AppleClang 4.0+. 2015-01-11 16:52:05 +01:00
Robert Maynard 64c30bdc48 Features: Record for MSVC C++ 2015 and MSVC C 2010-2015.
Initializer lists are only properly supported in 2015 and above.
Previous Visual Studio releases said they supported initializer lists
but silently produced bad code.
2015-01-11 16:47:58 +01:00
Stephen Kelly 225c0ef88b Features: Record for MSVC 2010-2013. 2015-01-11 16:47:58 +01:00
Stephen Kelly 998ed4ca0a Features: Record cxx_variable_templates for GNU 5.0. 2015-01-01 22:00:49 +01:00
Brad King be1109d811 Oracle/Sun: Fix Fortran preprocessor rule generation
The SunPro Fortran compiler uses "-F" instead of "-E" to request
preprocessing.  The output does not go to stdout so use "-o" to
specify the output file.

This fixes the guess originally made by commit b6b37e30 (Makefile: Add
assembly and preprocessed targets for Fortran, 2014-11-05).
2014-12-23 10:15:27 -05:00
Stephen Kelly bd6b42c186 Features: Record for AppleClang 5.1
Apple's Clang 5.1 already supports most of the C and C++ features CMake
enumerates.
2014-12-22 10:44:41 -05:00
Brad King 5a611495c2 Merge topic 'C-features-Wundef'
d0af0fae WCDH: Make the header -Wundef safe for the C language.
2014-11-26 10:37:46 -05:00
Brad King 47f1020b54 Merge topic 'fix-GNU-CXX-dialect-versions'
c03c184b Features: Record C++11 dialect switch only for GNU 4.7 and later.
2014-11-25 10:18:42 -05:00
Stephen Kelly d0af0faefb WCDH: Make the header -Wundef safe for the C language.
The __STDC_VERSION__ macro may be defined or not depending on the
implementation dialect of C.  Test that it is defined before testing
its value.

The CXX tests do not need such a change because they define __cplusplus
in all dialects.
2014-11-25 14:44:21 +01:00
Stephen Kelly f327a9fd26 Merge branch 'default-lang-dialect' into step2
Conflicts:
	Modules/Compiler/Clang-C.cmake
2014-11-20 22:11:56 +01:00
Stephen Kelly a3d0ae1758 Features: Fix the default C dialect for Clang and GNU.
Clang 3.4 uses C99 by default, and Clang 3.6 uses C11 by default:

 http://thread.gmane.org/gmane.comp.compilers.clang.devel/39379

GNU 4.9 uses C90 by default, and GNU 5.0 uses C11 by default:

 https://gcc.gnu.org/gcc-5/changes.html

Test that the default compiler settings result in the expected dialect
macros being defined for both C and CXX.  Remove the unused main.c
file from the CompileFeatures unit test.
2014-11-20 18:24:59 +01:00
Fraser Hutchison 4d52cd36ad Avoid if() quoted auto-dereference when checking for "MSVC"
When testing CMAKE_<LANG>_COMPILER_ID values against "MSVC", do not
allow the definition of the "MSVC" variable to be expanded.
2014-11-19 16:24:54 -05:00
Stephen Kelly c03c184be0 Features: Record C++11 dialect switch only for GNU 4.7 and later.
Previous versions of GNU are not currently supported by this
CMake feature.
2014-11-19 09:39:44 +01:00
Stephen Kelly 49e2b689a8 Features: Fix references to CXX compiler version in Clang-C.cmake. 2014-11-19 00:42:51 +01:00
Brad King a9a040e169 Merge topic 'no-AppleClang-C-features'
ded30405 Features: Don't record for AppleClang
2014-11-13 10:08:37 -05:00
Stephen Kelly ded30405b2 Features: Don't record for AppleClang
Features are currently recorded accidentally for all versions of
AppleClang > 3.4 (I have no idea how that relates to upstream
Clang). Presumably that version has the features which are
accidentally recorded, but in the future features will be
recorded initially for only AppleClang >= 5.1, which would
appear as a feature regression.

Commit v3.1.0-rc1~635^2~11 (Don't load Clang-CXX from
AppleClang-CXX., 2013-11-11) ajusted the logic for the CXX
language.  Make a similar change for the C language.
2014-11-12 23:20:36 +01:00
Stephen Kelly 32b91b9e01 Features: Run GNU feature tests with std=c++14 when available. 2014-11-12 22:59:17 +01:00
Stephen Kelly 82c283f914 Features: Use the correct dialect flag when recording features.
Avoid using -std=c++1y for compilers which support -std=c++14, for
example.
2014-11-12 22:59:17 +01:00
Stephen Kelly b18155b788 Features: Reorder the GNU C dialect feature tests
This doesn't make a difference, but the consistency with other files
is easier to reason about.
2014-11-12 22:59:14 +01:00
Stephen Kelly e68d5c6000 Features: Split the Clang testable features to a separate file.
These tests can be shared with the AppleClang compile feature tests.
2014-11-11 23:01:07 +01:00
Tim Gallagher b6b37e3037 Makefile: Add assembly and preprocessed targets for Fortran
Extend the FortranOnly test to cover "make <src>.i" targets.
2014-11-10 10:24:53 -05:00
Stephen Kelly 49b8140e5d Clang: Enable c++14 dialect flag with Clang 3.5. 2014-09-17 14:57:07 +02:00
Stephen Kelly 0b80fc350a Clang: Don't overwrite c++11 compile option value with c++14 flag. 2014-09-17 14:56:16 +02:00
Erik Lindahl 0578c283e8 Add Fujitsu compiler detection
The Fujitsu C/C++ compilers are the default ones for K computer.
Detect both native and cross compilers by looking for the __FUJITSU
preprocessor definition.
2014-08-11 10:31:06 -04:00
Brad King c86b99c351 Merge topic 'fix-QCC-compile-flags'
3151024d QNX: Add missing flags for configurations and artifact creation.
2014-07-21 10:36:07 -04:00
Stephen Kelly 3151024d24 QNX: Add missing flags for configurations and artifact creation.
Commit v3.0.0-rc1~111^2 (QNX: Introduce QCC compiler id for that
QNX platform compiler., 2014-01-20) split handling of the QNX QCC
compiler into a separate compiler-id.  That refactoring results in
the QCC compiler not using the CMake-compiler-id "GNU", which means
that the __compiler_gnu macro is no longer executed for it.

Add Compiler/QCC*.cmake modules to define and call the __compiler_qcc
macro and teach it to call __compiler_gnu internally.  Remove the
corresponding pieces from the Platform/QNX*.cmake modules.

It is also necessary to change the language conditional to dereference
the lang macro parameter, which is another bug introduced by the
same commit.  The extra -lang-c++ flag is only necessary when the CXX
compiler is specified as 'qcc' instead of 'QCC' in the toolchain file,
which is why this bug was not noticed before.  The flag is also necessary
in that case when linking in order to find the appropriate standard
libraries.  The flag was not previously added when linking executables,
so linking failed even with CMake 2.8.12 with the lower-case compiler-id.

Co-Author: Brad King <brad.king@kitware.com>
2014-07-17 09:36:18 -04:00
Stephen Kelly b70295760c Project: Add configurable name for version computation macros. 2014-06-05 14:02:52 +02:00
Stephen Kelly 78acaafebe Project: Separate simulated compiler id from version detection. 2014-06-05 14:02:52 +02:00
Stephen Kelly dd043c3f21 Features: Add support for C++14 features.
Record the features implemented by GNU 4.9 and Clang 3.4.
2014-05-22 18:01:23 +02:00
Stephen Kelly cda233194f Features: Record for Clang 3.4
Clang 3.4 supports all features currently known to CMake.
2014-05-20 16:03:48 +02:00
Brad King c1edede31f Merge topic 'compile-features-C-language'
e0890d03 Features: Extend concept to C language.
2014-05-20 09:40:14 -04: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 5c04dfe465 Features: Only require AppleClang policy to be NEW on APPLE. 2014-05-14 23:55:34 +02:00
Brad King e506f1f16e Merge topic 'features-gnu-oldest-supported'
f782417b Features: Record the oldest supported compiler.
2014-05-12 09:31:08 -04:00
Stephen Kelly 5109b0428d Features: Fix GNU 4.8.1 version test. 2014-05-10 08:58:49 +02:00
Stephen Kelly f5bf9d4311 Tests: Make CompileFeature tests use highest standard known.
Remove the use of check_cxx_source_compiles which is now just getting in
the way.

Blacklist the cxx_alignof feature in the test with GNU 4.7. The test
file compiles, but it is documented as available first in GNU 4.8.
2014-05-09 14:39:30 +02:00
Stephen Kelly f782417b8c Features: Record the oldest supported compiler.
This may be used to ensure that features are reported correctly
only if the compiler minimum version is met.
2014-05-08 18:02:14 +02:00
Brad King f1d504d6cd Merge topic 'GNU-4.7-features'
9cbc63e4 Features: Record for GNU 4.7.
2014-05-08 11:28:03 -04: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
Brad King 9add7071a5 Merge topic 'hp-cpp98-tests'
b0f277db HP aCC: record compiler flag for Ansi C++98 support for version 3.80 onwards
2014-05-08 11:27:55 -04:00
Brad King 7b3def93b6 Merge topic 'decay-language-version'
205215fb cmTarget: Add CXX_STANDARD_REQUIRED to control decay.
1df2116b Features: Decay language flag if requested is not available.
c4f4dac2 Project: Fix exit-on-error with compile feature tests.
5bb7ce72 Project: Use nullary form of main for compile feature tests.
64254e7a Project: Remove extern from static string in feature tests.
0d9c99bf Help: Fix order of help entries.
dc7639bd Tests: Fix name of cache variable.
2014-05-08 11:27:53 -04:00
Stephen Kelly 9cbc63e40c Features: Record for GNU 4.7.
Update the CompileFeatures test to verify that unsupported features
do not work.
2014-05-07 22:02:02 +02:00
Stephen Kelly 3b59f8b7c6 Project: Refactor C compiler determination into multiple files. 2014-05-07 14:28:36 +02:00
Stephen Kelly 8896501b23 CompilerId: Allow specifying a prefix for preprocessor defines. 2014-05-07 14:00:01 +02:00
Stephen Kelly 9d285600d4 Project: Generate the CXX compiler Id test from multiple files.
This will allow sharing of the logic of the order to test compilers in
and the preprocessor macros used to do that and to determine the
version components.
2014-05-07 14:00:00 +02:00
Stephen Kelly aa283b6b01 Features: Fix test for GNU 4.8.1. 2014-05-07 12:40:42 +02:00
Stephen Kelly 1df2116bfa Features: Decay language flag if requested is not available.
Use the highest standard compile flags available if requested language
version is too new.

This supports use-cases like

 set(CMAKE_CXX_STANDARD 14)

 # Compiled with -std=c++11 with GNU 4.7, which has no -std=c++14
 # or equivalent flag
 add_executable(main main.cpp)

This can be used in combination with preprocessor defines which
communicate the availability of certain language features for
optional use.
2014-05-07 12:17:49 +02:00
Stephen Kelly c4f4dac2d5 Project: Fix exit-on-error with compile feature tests. 2014-05-07 12:16:14 +02:00
Rolf Eike Beer b0f277db38 HP aCC: record compiler flag for Ansi C++98 support for version 3.80 onwards
Old versions of aCC need a special compiler flag to get full C++98 template
support as e.g. CMake itself or the Complex and ComplexOneConfig tests need.
The same versions need a special flag to get a proper C++ library, too.
2014-04-25 17:59:57 +02:00
Stephen Kelly a36b957fc4 Features: Add cxx_template_template_parameters.
Extend the existing feature infrastructure as needed to support
both C++11 and C++98 features.
2014-04-16 15:16:23 +02:00
Stephen Kelly 60c0d2dd81 Features: Add cxx_defaulted_move_initializers. 2014-04-08 11:05:58 +02:00
Stephen Kelly c4e672358c Features: Add cxx_long_long_type. 2014-04-08 11:05:58 +02:00
Stephen Kelly dcaafada0e Features: Add cxx_func_identifier. 2014-04-08 11:05:57 +02:00
Stephen Kelly 251a1f02a0 Features: Add cxx_local_type_template_args. 2014-04-08 11:05:57 +02:00
Stephen Kelly 53fe7773e6 Features: Add cxx_extended_friend_declarations. 2014-04-08 11:05:57 +02:00
Stephen Kelly 16603f7cdb Features: Add cxx_enum_forward_declarations. 2014-04-08 11:05:57 +02:00
Stephen Kelly adf22f611e Features: Add cxx_default_function_template_args. 2014-04-08 11:05:57 +02:00
Stephen Kelly 7b3e8a0534 Features: Add cxx_right_angle_brackets. 2014-04-08 11:05:57 +02:00
Stephen Kelly 9a49fd21be Features: Add cxx_decltype_incomplete_return_types. 2014-04-08 11:05:57 +02:00
Stephen Kelly 1889045ca6 Features: Add cxx_sizeof_member. 2014-04-08 11:05:57 +02:00
Stephen Kelly ab455ebafd Features: Add cxx_thread_local. 2014-04-08 11:05:57 +02:00
Stephen Kelly 300ce2481e Features: Add cxx_inline_namespaces. 2014-04-08 11:05:57 +02:00
Stephen Kelly f9d04a96b5 Features: Add cxx_variadic_macros. 2014-04-08 11:05:57 +02:00
Stephen Kelly 3d76656fb3 Features: Add cxx_uniform_initialization. 2014-04-08 11:05:56 +02:00
Stephen Kelly e74b216c90 Features: Add cxx_generalized_initializers. 2014-04-08 11:05:56 +02:00
Stephen Kelly ff80c3b420 Features: Add cxx_attributes. 2014-04-08 11:05:56 +02:00
Stephen Kelly 7605fee593 Features: Add cxx_alignof. 2014-04-08 11:05:56 +02:00
Stephen Kelly e7d6e1f44f Features: Add cxx_alignas.
cxx_alignof will be a separate feature known to CMake, because
both can be implemented with separate backward compatibility
versions.
2014-04-08 11:05:56 +02:00
Stephen Kelly 32c2acd65c Features: Add cxx_extern_templates. 2014-04-08 11:05:56 +02:00
Stephen Kelly 9064f78b0c Features: Add cxx_unrestricted_unions. 2014-04-08 11:05:56 +02:00
Stephen Kelly 3322b393a2 Features: Add cxx_unicode_literals. 2014-04-08 11:05:56 +02:00
Stephen Kelly 04c5b99f38 Features: Add cxx_user_literals. 2014-04-08 11:05:56 +02:00
Stephen Kelly e1e292cd06 Features: Add cxx_alias_templates. 2014-04-08 11:05:56 +02:00
Stephen Kelly 3300f78310 Features: Add cxx_rvalue_references. 2014-04-08 11:05:55 +02:00