• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# Copyright 2021-2023 Huawei Technologies Co., Ltd
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15# ============================================================================
16
17# Find a suitable LLVM version for AKG.
18#
19# This file generates a temporary cmake script file
20# and executes it by `cmake -P` (cmake script mode).
21#
22# If no suitable LLVM is found, the `find_package` function runs normally,
23# the `cmake` command exits with status `0`.
24#
25# If suitable LLVM is found, the `find_package` will encounter the error
26# "add_library command is not scriptable" in `LLVMExports.cmake` of LLVM library.
27# This error is caused because of running `cmake` in script mode.
28# Finally the `cmake` command exit with status `1`.
29
30echo "find_package(LLVM 16 QUIET)" > akg_llvm_tmp.cmake
31echo "find_package(LLVM 15 QUIET)" >> akg_llvm_tmp.cmake
32echo "find_package(LLVM 14 QUIET)" >> akg_llvm_tmp.cmake
33echo "find_package(LLVM 13 QUIET)" >> akg_llvm_tmp.cmake
34echo "find_package(LLVM 12 QUIET)" >> akg_llvm_tmp.cmake
35cmake -P akg_llvm_tmp.cmake > /dev/null 2>&1
36result=$?
37rm akg_llvm_tmp.cmake
38
39if [  ${result} -eq 0 ]; then
40    echo "off"
41else
42    echo "on"
43fi
44
45
46