1# Copyright (c) 2021-2022 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14set(TOOLCHAIN_CLANG_ROOT "" CACHE STRING "Path to clang-<version> directory") 15set(TOOLCHAIN_SYSROOT "" CACHE STRING "Path to sysroot") 16 17set(PANDA_TRIPLET aarch64-linux-ohos) 18set(PANDA_SYSROOT ${TOOLCHAIN_SYSROOT}) 19 20set(CMAKE_SYSTEM_NAME OHOS) 21set(CMAKE_SYSTEM_PROCESSOR aarch64) 22set(CMAKE_PREFIX_PATH ${TOOLCHAIN_SYSROOT}) 23set(CMAKE_C_COMPILER_TARGET ${PANDA_TRIPLET}) 24set(CMAKE_CXX_COMPILER_TARGET ${PANDA_TRIPLET}) 25set(CMAKE_ASM_COMPILER_TARGET ${PANDA_TRIPLET}) 26 27link_libraries(unwind) 28 29if(NOT PANDA_TOOLCHAIN_INITIALIZED) 30 # Toolchain file can be sourced multiple times with different sets of variables. 31 # Prevent failures if TOOLCHAIN_CLANG_ROOT is not set this time but still fail 32 # if TOOLCHAIN_CLANG_ROOT is not specified at all. 33 if(NOT TOOLCHAIN_CLANG_ROOT) 34 set(CMAKE_AR "/bin/false" CACHE FILEPATH "") 35 set(CMAKE_RANLIB "/bin/false" CACHE FILEPATH "") 36 set(CMAKE_C_COMPILER "/bin/false" CACHE FILEPATH "") 37 set(CMAKE_CXX_COMPILER "/bin/false" CACHE FILEPATH "") 38 else() 39 set(CMAKE_AR "${TOOLCHAIN_CLANG_ROOT}/bin/llvm-ar" CACHE FILEPATH "" FORCE) 40 set(CMAKE_RANLIB "${TOOLCHAIN_CLANG_ROOT}/bin/llvm-ranlib" CACHE FILEPATH "" FORCE) 41 set(CMAKE_C_COMPILER "${TOOLCHAIN_CLANG_ROOT}/bin/clang" CACHE FILEPATH "" FORCE) 42 set(CMAKE_CXX_COMPILER "${TOOLCHAIN_CLANG_ROOT}/bin/clang++" CACHE FILEPATH "" FORCE) 43 endif() 44 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --rtlib=compiler-rt -fuse-ld=lld" CACHE STRING "" FORCE) 45 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --rtlib=compiler-rt -fuse-ld=lld" CACHE STRING "" FORCE) 46 # Do not add linker flags multiple times when variables persist across toolchain file invocation. 47 set(PANDA_TOOLCHAIN_INITIALIZED ON CACHE STRING "" FORCE) 48endif() 49