1# Copyright (c) 2021-2024 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 14option(TOOLCHAIN_CLANG_ROOT "Path to clang-<version> directory" "") 15option(TOOLCHAIN_SYSROOT "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 27add_compile_definitions(__MUSL__) 28 29# Toolchain file can be sourced multiple times with different sets of variables. 30# Prevent failures if TOOLCHAIN_CLANG_ROOT is not set this time but still fail 31# if TOOLCHAIN_CLANG_ROOT is not specified at all. 32if(NOT TOOLCHAIN_CLANG_ROOT) 33 set(CMAKE_AR "/bin/false" CACHE FILEPATH "") 34 set(CMAKE_RANLIB "/bin/false" CACHE FILEPATH "") 35 set(CMAKE_C_COMPILER "/bin/false" CACHE FILEPATH "") 36 set(CMAKE_CXX_COMPILER "/bin/false" CACHE FILEPATH "") 37else() 38 set(CMAKE_AR "${TOOLCHAIN_CLANG_ROOT}/bin/llvm-ar" CACHE FILEPATH "" FORCE) 39 set(CMAKE_RANLIB "${TOOLCHAIN_CLANG_ROOT}/bin/llvm-ranlib" CACHE FILEPATH "" FORCE) 40 set(CMAKE_C_COMPILER "${TOOLCHAIN_CLANG_ROOT}/bin/clang" CACHE FILEPATH "" FORCE) 41 set(CMAKE_CXX_COMPILER "${TOOLCHAIN_CLANG_ROOT}/bin/clang++" CACHE FILEPATH "" FORCE) 42endif() 43set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libstdc++ -Wl,-rpath,\\\$ORIGIN " CACHE STRING "" FORCE) 44set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} " CACHE STRING "" FORCE) 45set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname," CACHE STRING "" FORCE) 46set(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-Wl,-soname," CACHE STRING "" FORCE) 47