xref: /oneTBB/cmake/toolchains/riscv64.cmake (revision e8e550e8)
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.
16if (RISCV_TOOLCHAIN_INCLUDED)
17    return()
18endif()
19set(RISCV_TOOLCHAIN_INCLUDED TRUE)
20
21set(CMAKE_SYSTEM_NAME Linux)
22set(CMAKE_SYSTEM_VERSION 1)
23set(CMAKE_SYSTEM_PROCESSOR riscv)
24
25# User can use -DCMAKE_FIND_ROOT_PATH to specific toolchain path
26set(CMAKE_C_COMPILER ${CMAKE_FIND_ROOT_PATH}/bin/riscv64-unknown-linux-gnu-clang)
27set(CMAKE_CXX_COMPILER ${CMAKE_FIND_ROOT_PATH}/bin/riscv64-unknown-linux-gnu-clang++)
28set(CMAKE_LINKER ${CMAKE_FIND_ROOT_PATH}/bin/riscv64-unknown-linux-gnu-ld)
29
30set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
31set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
32
33# Most linux on riscv64 support rv64imafd_zba_zbb extensions
34set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=rv64imafd_zba_zbb -mabi=lp64d " CACHE INTERNAL "")
35