From 92c45b4006b7a5f2b34a1750160d967e3992b868 Mon Sep 17 00:00:00 2001 From: Shreyas Ananthan Date: Wed, 21 Apr 2021 15:55:37 -0600 Subject: [PATCH] Update rules for Intel OneAPI compiler detection (#727) * Update rules for Intel OneAPI compiler detection CMake 3.20 differentiates between older Intel compilers and the Intel OneAPI compilers (which is now detected as `IntelLLVM`). This commit introduces the necessary changes to CMake logic to allow building using OneAPI compiler stack with the latest CMake version. * Update CMake check for Intel compiler (#1) Co-authored-by: Rafael M Mudafort --- CMakeLists.txt | 2 +- cmake/OpenfastFortranOptions.cmake | 6 +++--- modules/nwtc-library/CMakeLists.txt | 6 +++--- share/discon/CMakeLists.txt | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0dd8cdee43..998caa12b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,7 +68,7 @@ if (FPE_TRAP_ENABLED) endif (FPE_TRAP_ENABLED) # Setup dependencies -if (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") +if (${CMAKE_Fortran_COMPILER_ID} MATCHES "^Intel") find_package(MKL) endif() if (MKL_FOUND) diff --git a/cmake/OpenfastFortranOptions.cmake b/cmake/OpenfastFortranOptions.cmake index 70126e17ef..4e02fd4633 100644 --- a/cmake/OpenfastFortranOptions.cmake +++ b/cmake/OpenfastFortranOptions.cmake @@ -42,7 +42,7 @@ macro(set_fast_fortran) # Abort if we do not have gfortran or Intel Fortran Compiler. if (NOT (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU" OR - ${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")) + ${CMAKE_Fortran_COMPILER_ID} MATCHES "^Intel")) message(FATAL_ERROR "OpenFAST requires either GFortran or Intel Fortran Compiler. Compiler detected by CMake: ${FCNAME}.") endif() @@ -54,7 +54,7 @@ macro(set_fast_fortran) elseif("${CMAKE_Fortran_COMPILER_VERSION}" VERSION_LESS "4.6.0") message(FATAL_ERROR "A version of GNU GFortran greater than 4.6.0 is required. GFortran version detected by CMake: ${CMAKE_Fortran_COMPILER_VERSION}.") endif() - elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel") + elseif(${CMAKE_Fortran_COMPILER_ID} MATCHES "^Intel") if("${CMAKE_Fortran_COMPILER_VERSION}" VERSION_LESS "11") message(FATAL_ERROR "A version of Intel ifort greater than 11 is required. ifort version detected by CMake: ${CMAKE_Fortran_COMPILER_VERSION}.") endif() @@ -68,7 +68,7 @@ macro(set_fast_fortran) # Get OS/Compiler specific options if (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU") set_fast_gfortran() - elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel") + elseif(${CMAKE_Fortran_COMPILER_ID} MATCHES "^Intel") set_fast_intel_fortran() endif() endmacro(set_fast_fortran) diff --git a/modules/nwtc-library/CMakeLists.txt b/modules/nwtc-library/CMakeLists.txt index 4630e604ef..7bf80a9b3c 100644 --- a/modules/nwtc-library/CMakeLists.txt +++ b/modules/nwtc-library/CMakeLists.txt @@ -61,7 +61,7 @@ if (CMAKE_BUILD_TYPE MATCHES Debug) set_source_files_properties(src/NetLib/slatec/NWTC_SLATEC.f90 PROPERTIES COMPILE_FLAGS -frecursive) set_source_files_properties(src/NetLib/slatec/dqk61.f PROPERTIES COMPILE_FLAGS -frecursive) set_source_files_properties(src/NetLib/slatec/qk61.f PROPERTIES COMPILE_FLAGS -frecursive) - elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel") + elseif (${CMAKE_Fortran_COMPILER_ID} MATCHES "^Intel") if("${CMAKE_Fortran_COMPILER_VERSION}" VERSION_LESS "19") if (WIN32) set_source_files_properties(src/NetLib/slatec/NWTC_SLATEC.f90 PROPERTIES COMPILE_FLAGS "/recursive") @@ -93,7 +93,7 @@ if(BUILD_OPENFAST_SIMULINK_API) if (APPLE OR UNIX) if (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU") set(NWTC_SYS_FILE src/SysMatlabLinuxGnu.f90) - elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel") + elseif (${CMAKE_Fortran_COMPILER_ID} MATCHES "^Intel") set(NWTC_SYS_FILE src/SysMatlabLinuxIntel.f90) endif() elseif (WIN32) @@ -106,7 +106,7 @@ elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU") elseif (APPLE OR UNIX OR CYGWIN) set(NWTC_SYS_FILE src/SysGnuLinux.f90) endif () -elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel") +elseif (${CMAKE_Fortran_COMPILER_ID} MATCHES "^Intel") if (APPLE OR UNIX) set(NWTC_SYS_FILE src/SysIFL.f90) elseif (WIN32) diff --git a/share/discon/CMakeLists.txt b/share/discon/CMakeLists.txt index 7ca94e253a..c6814bcbed 100644 --- a/share/discon/CMakeLists.txt +++ b/share/discon/CMakeLists.txt @@ -72,7 +72,7 @@ endif (NOT CMAKE_BUILD_TYPE) # set the build flags if (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU") set_gfortran() -elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel") +elseif(${CMAKE_Fortran_COMPILER_ID} MATCHES "^Intel") set_ifort() endif() set(CMAKE_SHARE_LINKER_FLAGS "-shared")