1# SPDX-License-Identifier: Apache-2.0 2# 3# Copyright (c) 2023 Intel Corporation 4# 5# Findarmclang module for locating arm clang compiler. 6# 7# The module defines the following variables: 8# 9# 'armclang_FOUND', 'ARMCLANG_FOUND' 10# True if the arm clang toolchain/compiler was found. 11# 12# 'ARMCLANG_VERSION' 13# The version of the arm clang toolchain. 14 15include(FindPackageHandleStandardArgs) 16 17if(CMAKE_C_COMPILER) 18 # Parse the 'clang --version' output to find the installed version. 19 execute_process(COMMAND ${CMAKE_C_COMPILER} --target=${triple} --version OUTPUT_VARIABLE ARMCLANG_VERSION ERROR_QUIET) 20 string(REPLACE "\n" ";" armclang_version_list "${ARMCLANG_VERSION}") 21 set(ARMCLANG_VERSION ARMCLANG_VERSION-NOTFOUND) 22 foreach(line ${armclang_version_list}) 23 # Compiler version is either terminated directly, or followed by space and extra build info. 24 if(line MATCHES ".*[aA]rm [cC]ompiler[^0-9]*([0-9.]+)($| .*$)") 25 set(ARMCLANG_VERSION "${CMAKE_MATCH_1}") 26 break() 27 endif() 28 endforeach() 29endif() 30 31find_package_handle_standard_args(armclang 32 REQUIRED_VARS CMAKE_C_COMPILER 33 VERSION_VAR ARMCLANG_VERSION 34) 35