| 1 |
# Copyright (c) 2023 Intel Corporation |
| 2 |
# |
| 3 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
# you may not use this file except in compliance with the License. |
| 5 |
# You may obtain a copy of the License at |
| 6 |
# |
| 7 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
# |
| 9 |
# Unless required by applicable law or agreed to in writing, software |
| 10 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
# See the License for the specific language governing permissions and |
| 13 |
# limitations under the License. |
| 14 |
|
| 15 |
# Prevent double invocation. |
| 16 |
if (RISCV_TOOLCHAIN_INCLUDED) |
| 17 |
return() |
| 18 |
endif() |
| 19 |
set(RISCV_TOOLCHAIN_INCLUDED TRUE) |
| 20 |
|
| 21 |
set(CMAKE_SYSTEM_NAME Linux) |
| 22 |
set(CMAKE_SYSTEM_VERSION 1) |
| 23 |
set(CMAKE_SYSTEM_PROCESSOR riscv) |
| 24 |
|
| 25 |
# User can use -DCMAKE_FIND_ROOT_PATH to specific toolchain path |
| 26 |
set(CMAKE_C_COMPILER ${CMAKE_FIND_ROOT_PATH}/bin/riscv64-unknown-linux-gnu-clang) |
| 27 |
set(CMAKE_CXX_COMPILER ${CMAKE_FIND_ROOT_PATH}/bin/riscv64-unknown-linux-gnu-clang++) |
| 28 |
set(CMAKE_LINKER ${CMAKE_FIND_ROOT_PATH}/bin/riscv64-unknown-linux-gnu-ld) |
| 29 |
|
| 30 |
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) |
| 31 |
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) |
| 32 |
|
| 33 |
# Most linux on riscv64 support rv64imafd_zba_zbb extensions |
| 34 |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=rv64imafd_zba_zbb -mabi=lp64d " CACHE INTERNAL "") |