diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index 54f5dcaa12..6e7f378c39 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -13,6 +13,42 @@ include(${CMAKE_ROOT}/Modules/CMakeParseLibraryArchitecture.cmake) include(CMakeTestCompilerCommon) function(CMAKE_DETERMINE_COMPILER_ABI lang src) + set(abi_variables + CMAKE_${lang}_COMPILER_WORKS + CMAKE_${lang}_COMPILER_ARCHITECTURE_ID + CMAKE_${lang}_STANDARD_INCLUDE_DIRECTORIES + CMAKE_${lang}_COMPILER_LINKER + CMAKE_${lang}_IMPLICIT_LINK_LIBRARIES + CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES + CMAKE_${lang}_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES + CMAKE_${lang}_LIBRARY_ARCHITECTURE) + if (CMAKE_${lang}_COMPILER_LINKER) + list(APPEND abi_variables + CMAKE_${lang}_COMPILER_LINKER_ID + CMAKE_${lang}_COMPILER_LINKER_VERSION + CMAKE_${lang}_COMPILER_LINKER_FRONTEND_VARIANT) + endif () + if (lang STREQUAL "Fortran") + list(APPEND abi_variables + CMAKE_${lang}_COMPILER_SUPPORTS_F90) + endif () + if (lang MATCHES "^(CUDA|HIP)$") + list(APPEND abi_variables + CMAKE_${lang}_ARCHITECTURES + CMAKE_${lang}_HOST_COMPILER_ID + CMAKE_${lang}_HOST_COMPILER_VERSION + CMAKE_${lang}_RUNTIME_LIBRARY) + endif () + set(all_abi_variables_defined 1) + foreach (abi_variable IN LISTS abi_variables) + if (NOT DEFINED "${abi_variable}") + set(all_abi_variables_defined 0) + break () + endif () + endforeach () + if (all_abi_variables_defined AND CMAKE_${lang}_COMPILER_WORKS) + set(CMAKE_${lang}_ABI_COMPILED 1) + endif () if(NOT DEFINED CMAKE_${lang}_ABI_COMPILED) message(CHECK_START "Detecting ${lang} compiler ABI info") diff --git a/Modules/CMakeTestFortranCompiler.cmake b/Modules/CMakeTestFortranCompiler.cmake index 04c790b3a8..4ca4f567b2 100644 --- a/Modules/CMakeTestFortranCompiler.cmake +++ b/Modules/CMakeTestFortranCompiler.cmake @@ -21,7 +21,9 @@ CMAKE_DETERMINE_COMPILER_ABI(Fortran ${CMAKE_ROOT}/Modules/CMakeFortranCompilerA if(CMAKE_Fortran_ABI_COMPILED) # The compiler worked so skip dedicated test below. set(CMAKE_Fortran_COMPILER_WORKS TRUE) - set(CMAKE_Fortran_COMPILER_SUPPORTS_F90 1) + if (NOT DEFINED CMAKE_Fortran_COMPILER_SUPPORTS_F90) + set(CMAKE_Fortran_COMPILER_SUPPORTS_F90 1) + endif () message(STATUS "Check for working Fortran compiler: ${CMAKE_Fortran_COMPILER} - skipped") else() cmake_determine_compiler_abi(Fortran ${CMAKE_ROOT}/Modules/CMakeFortranCompilerABI.F)