From b7193ab18f74a3b6eb6c24bac31384863ee87ffc Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 27 Apr 2021 12:27:29 -0400 Subject: Intel: Update Classic compiler version detection for 2021 The value of the `__INTEL_COMPILER` macro changed convention starting in version 2021. Fixes: #22120 --- Help/release/3.20.rst | 8 ++++++++ Modules/CMakeFortranCompilerId.F.in | 19 ++++++++++++++----- Modules/Compiler/Intel-DetermineCompiler.cmake | 23 ++++++++++++++++------- 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/Help/release/3.20.rst b/Help/release/3.20.rst index 86c6a86..d274c26 100644 --- a/Help/release/3.20.rst +++ b/Help/release/3.20.rst @@ -351,3 +351,11 @@ Changes made since CMake 3.20.0 include the following. iOS, tvOS and watchOS should now default to ``@rpath`` instead of using a full absolute path and failing at runtime when the library or framework is embedded in an application bundle (see :prop_tgt:`XCODE_EMBED_`). + +3.20.2 +------ + +* The Intel Classic 2021 compiler version numbers are now detected correctly + as having major version 2021. CMake 3.20.1 and below were not aware of a + change to the identification macro version scheme made by Intel starting + in version 2021, and detected the version as 20.2. diff --git a/Modules/CMakeFortranCompilerId.F.in b/Modules/CMakeFortranCompilerId.F.in index 0f547e9..143511b 100644 --- a/Modules/CMakeFortranCompilerId.F.in +++ b/Modules/CMakeFortranCompilerId.F.in @@ -38,12 +38,21 @@ # endif #elif defined(__INTEL_COMPILER) || defined(__ICC) PRINT *, 'INFO:compiler[Intel]' -# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100) -# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10) -# if defined(__INTEL_COMPILER_UPDATE) -# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE) +! __INTEL_COMPILER = VRP prior to 2021, and then VVVV for 2021 and later. +# if __INTEL_COMPILER < 2021 +# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100) +# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10) +# if defined(__INTEL_COMPILER_UPDATE) +# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE) +# else +# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10) +# endif # else -# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10) +# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER) +# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER_UPDATE) +! The third version component from --version is an update index, +! but no macro is provided for it. +# define COMPILER_VERSION_PATCH DEC(0) # endif # if defined(__INTEL_COMPILER_BUILD_DATE) # define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE) diff --git a/Modules/Compiler/Intel-DetermineCompiler.cmake b/Modules/Compiler/Intel-DetermineCompiler.cmake index c31aa77..3c1fde2 100644 --- a/Modules/Compiler/Intel-DetermineCompiler.cmake +++ b/Modules/Compiler/Intel-DetermineCompiler.cmake @@ -2,16 +2,25 @@ set(_compiler_id_pp_test "defined(__INTEL_COMPILER) || defined(__ICC)") set(_compiler_id_version_compute " - /* __INTEL_COMPILER = VRP */ -# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__INTEL_COMPILER/100) -# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__INTEL_COMPILER/10 % 10) -# if defined(__INTEL_COMPILER_UPDATE) -# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__INTEL_COMPILER_UPDATE) + /* __INTEL_COMPILER = VRP prior to 2021, and then VVVV for 2021 and later, + except that a few beta releases use the old format with V=2021. */ +# if __INTEL_COMPILER < 2021 || __INTEL_COMPILER == 202110 || __INTEL_COMPILER == 202111 +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__INTEL_COMPILER/100) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__INTEL_COMPILER/10 % 10) +# if defined(__INTEL_COMPILER_UPDATE) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__INTEL_COMPILER_UPDATE) +# else +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__INTEL_COMPILER % 10) +# endif # else -# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__INTEL_COMPILER % 10) +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__INTEL_COMPILER) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__INTEL_COMPILER_UPDATE) + /* The third version component from --version is an update index, + but no macro is provided for it. */ +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(0) # endif # if defined(__INTEL_COMPILER_BUILD_DATE) - /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */ + /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */ # define @PREFIX@COMPILER_VERSION_TWEAK @MACRO_DEC@(__INTEL_COMPILER_BUILD_DATE) # endif # if defined(_MSC_VER) -- cgit v0.12 From 9c479c7c40c64d0fbe41cba1b422303989c306f7 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 27 Apr 2021 12:58:24 -0400 Subject: IntelLLVM: Add special case for ifx 2021.1 version extraction The ifx beta versions forgot to define `__INTEL_LLVM_COMPILER`, and instead define `__INTEL_COMPILER == 201900`. Add a special case. Issue: #22120 --- Help/release/3.20.rst | 13 ++++++++----- Modules/CMakeFortranCompilerId.F.in | 8 ++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Help/release/3.20.rst b/Help/release/3.20.rst index d274c26..f77304f 100644 --- a/Help/release/3.20.rst +++ b/Help/release/3.20.rst @@ -47,11 +47,7 @@ Compilers * The ``icx``/``icpx`` C/C++ compilers on Linux, and the ``icx`` C/C++ compiler on Windows, are fully supported as of oneAPI 2021.1. - * The ``ifx`` Fortran compiler on Linux is partially supported. - As of oneAPI 2021.1, ``ifx`` does not define several identification - macros, so CMake identifies it as the classic ``Intel`` compiler. - This works in many cases because ``ifx`` accepts the same command line - parameters as ``ifort``. A future version of oneAPI may fix this. + * The ``ifx`` Fortran compiler on Linux is supported as of oneAPI 2021.1. * The ``ifx`` Fortran compiler on Windows is not yet supported. @@ -359,3 +355,10 @@ Changes made since CMake 3.20.0 include the following. as having major version 2021. CMake 3.20.1 and below were not aware of a change to the identification macro version scheme made by Intel starting in version 2021, and detected the version as 20.2. + +* The Intel oneAPI Fortran compiler is now identified as ``IntelLLVM``. + The oneAPI 2021.1 Fortran compiler is missing an identification macro, + so CMake 3.20.1 and below identified it as ``Intel``. CMake now has + a special case to recognize oneAPI 2021.1 Fortran as ``IntelLLVM``. + The oneAPI 2021.2 Fortran compiler defines the proper identification + macro and so is identified as ``IntelLLVM`` by all CMake 3.20 versions. diff --git a/Modules/CMakeFortranCompilerId.F.in b/Modules/CMakeFortranCompilerId.F.in index 143511b..7aa385e 100644 --- a/Modules/CMakeFortranCompilerId.F.in +++ b/Modules/CMakeFortranCompilerId.F.in @@ -36,6 +36,14 @@ # define COMPILER_VERSION_MINOR DEC(__INTEL_LLVM_COMPILER/100 % 100) # define COMPILER_VERSION_PATCH DEC(__INTEL_LLVM_COMPILER % 100) # endif +#elif defined(__INTEL_COMPILER) && __INTEL_COMPILER == 201900 + PRINT *, 'INFO:compiler[IntelLLVM]' +! ifx 2021.1 forgot to define __INTEL_LLVM_COMPILER. +! Instead it defines __INTEL_COMPILER == 201900. +# define COMPILER_VERSION_MAJOR DEC(2021) +# define COMPILER_VERSION_MINOR DEC(1) +# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE) +# define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE) #elif defined(__INTEL_COMPILER) || defined(__ICC) PRINT *, 'INFO:compiler[Intel]' ! __INTEL_COMPILER = VRP prior to 2021, and then VVVV for 2021 and later. -- cgit v0.12