• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1if(NOT DEFINED ENV{OHOS_SYSROOT_PATH})
2    message(FATAL_ERROR "No defined environment variable: OHOS_SYSROOT_PATH")
3endif()
4set(OHOS_SYSROOT_PATH "$ENV{OHOS_SYSROOT_PATH}")
5
6set(CMAKE_SYSTEM_NAME Generic)
7set(CMAKE_CXX_COMPILER_ID Clang)
8set(CMAKE_TOOLCHAIN_PREFIX llvm-)
9set(CMAKE_C_COMPILER clang)
10set(CMAKE_C_FLAGS "--target=arm-liteos -D__clang__ -march=armv7-a -w")
11set(CMAKE_CXX_COMPILER clang++)
12set(CMAKE_CXX_FLAGS "--target=arm-liteos -D__clang__ -march=armv7-a -w")
13set(MY_LINK_FLAGS "--target=arm-liteos --sysroot=${OHOS_SYSROOT_PATH}")
14set(CMAKE_LINKER clang)
15set(CMAKE_CXX_LINKER clang++)
16set(CMAKE_C_LINKER clang)
17set(CMAKE_C_LINK_EXECUTABLE
18    "${CMAKE_C_LINKER} ${MY_LINK_FLAGS} <FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
19set(CMAKE_CXX_LINK_EXECUTABLE
20    "${CMAKE_CXX_LINKER} ${MY_LINK_FLAGS} <FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
21set(CMAKE_SYSROOT ${OHOS_SYSROOT_PATH})
22
23find_path(GCC_PATH gcc)
24find_path(GXX_PATH g++)
25if(NOT ${GCC_PATH} STREQUAL "GCC_PATH-NOTFOUND" AND NOT ${GXX_PATH} STREQUAL "GXX_PATH-NOTFOUND")
26    set(FLATC_GCC_COMPILER ${GCC_PATH}/gcc)
27    set(FLATC_GXX_COMPILER ${GXX_PATH}/g++)
28endif()
29
30string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,--gc-sections")
31