| # SPDX-FileCopyrightText: The Eigen Authors | |
| # SPDX-License-Identifier: MPL-2.0 | |
| cmake_minimum_required(VERSION 3.18) | |
| include("${CMAKE_CURRENT_LIST_DIR}/../../cmake/EigenTesting.cmake") | |
| function(check_compiler id version frontend expected) | |
| set(CMAKE_CXX_COMPILER_ID "${id}") | |
| set(CMAKE_CXX_COMPILER_VERSION "${version}") | |
| set(CMAKE_CXX_COMPILER_FRONTEND_VARIANT "${frontend}") | |
| # No driver invocation, including for missing metadata. | |
| set(CMAKE_CXX_COMPILER "${CMAKE_CURRENT_LIST_DIR}/compiler-must-not-be-invoked") | |
| ei_get_compilerver(actual) | |
| if(NOT actual STREQUAL expected) | |
| message(FATAL_ERROR "Expected ${expected}, got ${actual}") | |
| endif() | |
| if(NOT CMAKE_CXX_COMPILER_ID STREQUAL id OR NOT CMAKE_CXX_COMPILER_VERSION STREQUAL version) | |
| message(FATAL_ERROR "Compiler metadata was modified") | |
| endif() | |
| endfunction() | |
| check_compiler(GNU 13.3.0 GNU gnu-13.3.0) | |
| check_compiler(Clang 18.1.3 GNU clang-18.1.3) | |
| check_compiler(Clang 18.1.3 MSVC clang-msvc-18.1.3) | |
| check_compiler(AppleClang 15.0.0 GNU appleclang-15.0.0) | |
| check_compiler(MSVC 19.40.33811 MSVC msvc-19.40.33811) | |
| check_compiler(Intel 2021.10.0 "" intel-2021.10.0) | |
| check_compiler(IntelLLVM 2025.0.0 GNU intelllvm-2025.0.0) | |
| check_compiler(IntelLLVM 2025.0.0 MSVC intelllvm-msvc-2025.0.0) | |
| check_compiler(PGI 19.10 "" pgi-19.10) | |
| check_compiler(NVHPC 25.1 "" nvhpc-25.1) | |
| foreach(version IN ITEMS 5.4.0 8.3.0 12.2.0) | |
| check_compiler(QCC "${version}" "" "qcc-${version}") | |
| endforeach() | |
| check_compiler(CustomCompiler 1.2 "" customcompiler-1.2) | |
| check_compiler(GNU "" "" gnu-unknown) | |
| check_compiler("" "" "" unknown-unknown) | |
| check_compiler("" 1.2 "" unknown-1.2) | |
| unset(CMAKE_CXX_COMPILER_ID) | |
| unset(CMAKE_CXX_COMPILER_VERSION) | |
| ei_get_compilerver(actual) | |
| if(NOT actual STREQUAL "unknown-unknown" OR DEFINED CMAKE_CXX_COMPILER_ID) | |
| message(FATAL_ERROR "Unset metadata was not preserved") | |
| endif() |