Commit Graph

80 Commits

Author SHA1 Message Date
David Tenty
cac5eb3df2 CompilerId: Ensure internal compiler version string is not optimized out
This was missed in commit 27579e9cf1 (FujitsuClang: Add support for the
Fujitsu compiler in Clang mode, 2020-12-22, v3.21.0-rc1~402^2~5).
2024-12-04 09:28:57 -05: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
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
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
Christoph Seitz
94df5b6ef1 Tasking: Add support for several compiler toolsets
Add support for the Tasking compiler toolset:

* TriCore Compiler Toolset 6.3 (with TriCore, ARM, MCS,
  8051 and PCP architecture compilers)
* SmartCode Compiler Toolset 10.1 (with TriCore, ARC, MCS,
  8051 architecture compilers)
* ARM Compiler 6.0
* MCS Complier 3.3
* 8051 Compiler 7.2

Fixes: #23756
2022-09-14 09:58:50 -04:00
Brad King
4ef6e27cb9 CompilerId: Fix default extensions check for Clang targeting MSVC ABI
In commit fc3a1cbdd8 (CompilerID: Compiler extensions default detection,
2021-05-29, v3.22.0-rc1~52^2~2), extensions were assumed to be `OFF`
for Clang targeting the MSVC ABI.  However, the `clang` and `clang++`
tools both seem to have extensions enabled by default even when
targeting the MSVC ABI.

This can be observed with the `RunCMake.CompileFeatures` test.
It fails with the GNU-like `clang/clang++` front-end, but removing
the above special case makes it pass.  The test passes either way
with the MSVC-like `clang-cl` front-end.
2022-02-03 12:06:00 -05:00
Raul Tambre
e13dd52535 XL: Detect default extensions mode for legacy compiler
The legacy non-Clang variant seems to support a GNU-like extensions mode, which
is the default. Enable detection for it.
2022-01-23 23:10:28 +02:00
Brad King
0fc8b2f61c CompilerId: Restore support for classic C by avoiding C++ style comments
C++ style comments were added by commit fc3a1cbdd8 (CompilerID: Compiler
extensions default detection, 2021-05-29, v3.22.0-rc1~52^2~2), but they
may not be supported by the default mode of some C compilers.  Use
C-style comments instead.  For consistency, do this for all languages.

Fixes: #22942
2021-11-23 10:00:31 -05:00
Raul Tambre
fc3a1cbdd8 CompilerID: Compiler extensions default detection 2021-09-28 21:24:53 +03:00
Raul Tambre
2adfd95d79 CompilerID: Rename language_dialect to language_standard
In Linux C++ terms dialect usually refers to having GNU extensions or not.
Change the name to better reflect that this is about the standard version.
2021-09-28 21:24:53 +03:00
Zack Galbreath
590553f322 Compilers: protect use of __has_include
If the compiler does not have __has_include, pretend the answer is always no
2021-06-07 19:25:09 +00:00
Brad King
33900e3c7c Merge topic 'cray-compiler-wrapper-detection'
13144e82cd Cray: Enable Cray compiler wrapper detection on all platforms

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5897
2021-03-11 08:09:33 -05:00
Justin LaPolla
13144e82cd Cray: Enable Cray compiler wrapper detection on all platforms
Previously were checking for the `__CRAYXC` and `__CRAYXE` predefined
macros.  These macros reflect the platform that the compiler wrapper is
running on, i.e. Cray XC and Cray XE machines.  They are not defined on
other platforms such as Apollo80.

Switch to the `__CRAYXT_COMPUTE_LINUX_TARGET` macro. The Cray cc/CC/ftn
wrappers always define this macro on the command line. This macro has
been in use for many years, and is believed to be a reliable way to
detect current and older Cray compiler wrappers.

Fixes: #21904
2021-03-10 12:13:17 -05:00
Brad King
2843a322c8 Merge topic 'CrayPrgEnv-detection'
23b101de60 Revert "Cray: Fix Cray compiler detection on new platforms"

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5889
2021-03-09 09:15:43 -05:00
Brad King
23b101de60 Revert "Cray: Fix Cray compiler detection on new platforms"
The justification in commit 9ee4a42813 (Cray: Fix Cray compiler
detection on new platforms, 2020-12-01, v3.19.2~26^2) confuses detection
of the CrayPrgEnv with identification of the Cray compiler.  The
change regressed detection of the CrayPrgEnv on non-Cray compilers.
Revert it pending further investigation into the original problem.

Fixes: #21894
2021-03-08 12:28:36 -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
Justin LaPolla
9ee4a42813 Cray: Fix Cray compiler detection on new platforms
Customer reported problems detecting the Cray compiler on their Apollo80
system. We were checking for the __CRAYXC and __CRAYXE predefined
macros. These macros reflect the platform that the compiler is running
on, i.e. Cray XC and Cray XE machines. Naturally, this didn't work on
Apollo80.

This commit uses the official Cray compiler identification macros which
are defined on every platform:

    CCE Version     C Macro     C++ Macro    Fortran Macro
    ============    ========    =========    =============
    version <  9    _CRAYC      _CRAYC       _CRAYFTN
    version >= 9    __cray__    __cray__     _CRAYFTN
2020-12-01 12:20:47 -05: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
Brad King
7fe580a362 Features: Add infrastructure for C++ 20 language standard
Issue: #17849
2018-03-27 07:40:54 -04:00
Brad King
b96ca728f1 Add infrastructure to detect secondary compiler version information
Create a `CMAKE_<LANG>_COMPILER_VERSION_INTERNAL` variable to hold
a secondary/internal compiler version number detected at the same
time as the primary compiler version.  This will be useful for some
compilers where we need such a number to determine correct usage.

Inspired-by: Stefan Andersson <tfosm@hotmail.com>
Suggested-by: Norbert Lange <norbert.lange@andritz.com>
Issue: #17264
2017-10-03 08:11:27 -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
Brad King
ae1a6815b6 Features: Add infrastructure for C++ 17 language standard
Issue: #16468
2016-12-02 11:22:46 -05:00
Chuck Atkins
0763a83655 Cray: Add macro tests to detect the Cray compiler wrappers 2015-12-07 11:09:15 -05:00
Brad King
c3dc8935ee Make C and C++ default dialect detection robust to advanced optimizations
In commit v3.4.0-rc1~71^2 (Project: Determine default language dialect
for the compiler, 2015-09-15) we added an "INFO:..." string to the
compiler id detection binary.  The value can be optimized out of the
compiler id binary unless we force it to be included by making the
program behavior depend on it at runtime.  Add references to the value
as we do for the other info strings already.

Gentoo-Issue: https://bugs.gentoo.org/show_bug.cgi?id=565744
2015-11-18 10:12:25 -05: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
9c9bc71256 QNX: Fix detection of QCC compiler id (#15349)
In commit v3.1.0-rc1~113^2 (Use a more reliable regex for extracting
binary INFO strings, 2014-09-03) the matching of INFO: strings was made
more strict and no longer matches just "INFO:qnxnto".  Use
"INFO:qnxnto[]" instead to conform to the new pattern.
2015-01-14 10:28:59 -05: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
c7ddd409fd Project: Clarify comment about platform-native compilers. 2014-05-07 12:48:11 +02:00
Jiri Malak
5d9aa66c91 Watcom: Introduce OpenWatcom compiler id and fix compiler version
Distinguish "Open Watcom" from old "Watcom" by introducing a new
"OpenWatcom" compiler id.  The __WATCOMC__ format is "VVRP" for Watcom
and "VVRP + 1100" for Open Watcom.
2014-03-17 15:00:59 -04:00
Brad King
eddabf9fcf CMake*CompilerId: Fix patch level for Intel >= 14.0 (#14806)
According to the Intel release notes:

 http://software.intel.com/sites/default/files/l-compiler-release-update.pdf

the __INTEL_COMPILER_UPDATE predefined macro was introduced to hold the
third version component.

Reported-by: Dirk Ribbrock <dirk.ribbrock@mathematik.uni-dortmund.de>
Co-Author: Rolf Eike Beer <kde@opensource.sf-tec.de>
2014-03-14 08:51:37 -04:00
Stephen Kelly
e00db59d6c QNX: Introduce QCC compiler id for that QNX platform compiler.
Introduce policy CMP0047 to control resetting the id for
compatibility.

De-duplicate content in the QNX platform file by including the GNU
one. QNX is a form of GNU platform.

Do not clear CMAKE_SHARED_LIBRARY_${lang}_FLAGS variables.  They
are populated again later by the Compiler/GNU.cmake file anyway.

Modify the CMAKE_CXX_COMPILE_OBJECT variable only when the QCC
compiler id is in use, and the language is CXX.  Use the QNX
recommended flag for QCC instead of the gcc compatible -x flag.

Populate new module files to handle system includes and depfiles
when using the QCC compiler.

Remove code which unsets the system include and depfiles related
variables.  When a GNU driver is used instead of the QCC one, the
appropriate flags will be used.  These variables were previously
cleared for lowest-common-denominator compatibility with both
drivers.
2014-01-22 08:47:32 -05:00
Brad King
3e04946f7b Require CMAKE_<LANG>_COMPILER to be found as a full path
All generators now support detection of the full path to the compiler, so
require it to be so.  This will allow CMake<LANG>Information.cmake and
other logic to assume the full path to the compiler tool is available.

The Makefile generators already rejected CMAKE_<LANG>_COMPILER values
that did not name an existing compiler.  Extend this error message to
all generators, make it occur as early as possible, and improve the
message with advice about how to set the compiler.  If the full path to
the compiler is not known, finish enabling languages with a fatal error
so configuration does not continue.

For now, allow the RC language compiler to not be a full path.  Later we
will need to detect the full path to "rc" under the VS IDE.

Add a RunCMake.CompilerNotFound test to cover failure cases.
Fix the RunCMake.CompilerChange test EmptyCompiler case to work
when configuration does not continue past enable_language.
2013-10-28 08:36:14 -04:00
Brad King
a85e17e660 Intel: When simulating MSVC, re-use Windows-MSVC (#14476)
Teach CMake(C|CXX|Fortran)CompilerId* to report the MSVC version
simulated by the Intel compiler, if any.  Refactor the Windows-Intel
platform information helper module to load Windows-MSVC instead of
duplicating the information.  Teach Windows-MSVC to understand when
it is loaded as the simulated Fortran compiler (its preprocessor is
simulated).
2013-10-18 09:55:59 -04:00
Brad King
12a7e2b10c Merge topic 'apple-clang-id'
1763c31 Set policy CMP0025 to NEW while building CMake itself
aa53ee5 Add policy CMP0025 for Apple Clang compiler id compatibility
ab65862 Clang: Add separate "AppleClang" compiler id
2013-10-09 10:21:28 -04:00
Brad King
ab65862417 Clang: Add separate "AppleClang" compiler id
Apple distributes their own Clang build with their own version numbers
that differ from upstream Clang.  Use the __apple_build_version__ symbol
to identify the Apple Clang compiler and report the Apple Build Version
as the fourth version component in CMAKE_<LANG>_COMPILER_VERSION.  Add
Compiler/AppleClang-<lang> and Platform/Darwin-AppleClang-<lang> modules
that simply include the upstream equivalents.

Fix comparisons of CMAKE_<LANG>_COMPILER_ID to Clang in CMake's own
source and tests to account for AppleClang.
2013-10-07 20:12:46 -04:00
Brad King
3d8356d486 Clang: Support Windows variants for GNU and MSVC (#13035, #14458)
Teach the compiler identification preprocessor tests to report when
Clang simulates MSVC, and what version.  If not MSVC, assume GNU.

Teach compiler information modules Clang-(C|CXX) to recognize when Clang
simulates MSVC and skip loading the GNU information.

Teach the Windows-MSVC platform information to recognize when it is
loaded as the simulated compiler and use that version information
instead of the real compiler's (different) version scheme.

Add platform modules Windows-Clang-(C|CXX) and support module
Windows-Clang to load either Windows-MSVC or Windows-GNU and wrap
the corresponding information macros.
2013-10-04 13:39:22 -04:00
Brad King
51ab85c398 CMakeDetermineCompilerId: Add notion of "simulated" id/version
Some compilers try to simulate other compilers as a drop-in replacement
supporting all the same command-line options and predefined preprocessor
macros.  In such cases it will be useful to have CMake load the compiler
information files for the simulated compiler instead of duplicating the
information.  Teach CMakeDetermineCompilerId to extract the simulated
compiler id and version when the compiler id detection provides it.
2013-10-04 13:25:06 -04:00
Alex Neundorf
d118b8b389 Add IAR to the CMakeDetectC(XX)CompilerID.c(pp).in
With the AVR IAR compiler this can't be found, but it works e.g. for the
ARM AVR compiler.

Alex
2013-04-15 09:14:35 -04:00
Alex Neundorf
b3015862e5 rename TI_DSP toolchain to TI, since it works also for the ARM compiler
Additionally, look for a special ar and strip

Alex
2013-03-14 21:47:59 +01:00
Patrick Gansterer
8e85822e2b VS: Add the entry point when compiling for WindowsCE
Set the entry point to mainACRTStartup to make sure that main()
can be found when linking the application to check the compiler.
2012-11-30 15:15:06 +01:00
Patrick Gansterer
40c36c9f7b VS: Make DetermineCompilerId working with WinCE too
Add a dummy mainCRTStartup() function, since the linker searches for
it instead of main() and set the CMAKE_SYSTEM_* variables depending
on the MSVC_C_ARCHITECTURE_ID and CMAKE_VS_WINCE_VERSION variables.
2012-11-27 08:31:19 -05:00
Brad King
fccf19f49b Fix PathScale compiler id for Clang-based upstream
Upstream PathScale now uses Clang as its front-end.  Test for __PATHCC__
before __clang__.

Reported-by: C. Bergström <cbergstrom@pathscale.com>
2012-11-05 08:33:54 -05:00
Brad King
e9bc502fb8 Detect Analog VisualDSP++ compiler version with its id
Decode hex digits from __VISUALDSPVERSION__ to compute the version
number components.  Note that the constant encodes decimal digits as hex
digits (never larger than 9).  We represent them as decimal after
extraction.  See documentation at:

  http://download.analog.com/dsp/tools/VisualDSP_45_Update_6_Release_Note_v4.pdf
  http://www.analog.com/static/imported-files/software_manuals/50_asm_man.rev3.1.pdf

Note that __VISUALDSPVERSION__ was introduced in version 4.5.6.
2012-08-22 11:48:07 -04:00
Brad King
cca386b0a0 Detect Cray compiler version with its id
Decode decimal digits from

  _RELEASE
  _RELEASE_MINOR

to compute version number components.  See documentation at:

  http://docs.cray.com/books/S-2179-52/html-S-2179-52/zfixed5fvzxnxo.html
  http://sourceforge.net/p/predef/wiki/Compilers/#cray-c
2012-08-22 11:31:33 -04:00