• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2025 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 arm-linux-ohos)
18set(PANDA_SYSROOT ${TOOLCHAIN_SYSROOT})
19set(PANDA_TARGET_ARM32_ABI_SOFTFP 1)
20
21set(CMAKE_SYSTEM_NAME OHOS)
22set(CMAKE_SYSTEM_PROCESSOR arm)
23set(CMAKE_PREFIX_PATH ${TOOLCHAIN_SYSROOT})
24set(CMAKE_C_COMPILER_TARGET ${PANDA_TRIPLET})
25set(CMAKE_CXX_COMPILER_TARGET ${PANDA_TRIPLET})
26set(CMAKE_ASM_COMPILER_TARGET ${PANDA_TRIPLET})
27
28add_compile_definitions(__MUSL__)
29
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.
33if(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 "")
38else()
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)
43endif()
44set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libstdc++ -Wl,-rpath,\\\$ORIGIN " CACHE STRING "" FORCE)
45set(CMAKE_EXE_LINKER_FLAGS    "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ "    CACHE STRING "" FORCE)
46set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname," CACHE STRING "" FORCE)
47set(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-Wl,-soname," CACHE STRING "" FORCE)
48set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv7-a -mfloat-abi=softfp")
49set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv7-a -mfloat-abi=softfp")
50set(CMAKE_ASM_FLAGS "${CMAKE_CXX_FLAGS} -march=armv7-a -mfloat-abi=softfp")
51