Skip to content

Commit

Permalink
[infra/onert] Update cmake toolchain file (#14498)
Browse files Browse the repository at this point in the history
This commit updates cmake toolchain file
- Remove tizen cross build toolchain file: not used
- Support clang build: Set USE_CLANG=1 environment variable
- Remove deprecated include: CMakeForceCompiler
- Remove using envoption()

ONE-DCO-1.0-Signed-off-by: Hyeongseok Oh <[email protected]>
  • Loading branch information
hseok-oh authored Dec 27, 2024
1 parent 5913f43 commit 0889d96
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 74 deletions.
8 changes: 7 additions & 1 deletion infra/nnfw/cmake/buildtool/config/config_armv7l-linux.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,11 @@ set(FLAGS_COMMON ${FLAGS_COMMON}
"-mfloat-abi=hard"
"-mfpu=neon-vfpv4"
"-ftree-vectorize"
"-mfp16-format=ieee"
)

# "fp16-format=ieee" is default and not supported flag on Clang
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag(-mfp16-format=ieee COMPILER_SUPPORTS_FP16_FORMAT_I3E)
if(COMPILER_SUPPORTS_FP16_FORMAT_I3E)
set(FLAGS_COMMON ${FLAGS_COMMON} "-mfp16-format=ieee")
endif()
25 changes: 16 additions & 9 deletions infra/nnfw/cmake/buildtool/cross/toolchain_aarch64-linux.cmake
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
#
# config for aarch64-linux
#
include(CMakeForceCompiler)

# Set CMAKE_SYSTEM_NAME to notify to cmake that we are cross compiling
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)

set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)

# where is the target environment
set(NNAS_PROJECT_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../../..")
set(ROOTFS_AARCH64 "${NNAS_PROJECT_SOURCE_DIR}/tools/cross/rootfs/aarch64")
include("${NNAS_PROJECT_SOURCE_DIR}/infra/cmake/modules/OptionTools.cmake")
if(DEFINED ENV{USE_CLANG} AND "$ENV{USE_CLANG}" STREQUAL "1")
set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)
set(CMAKE_C_COMPILER_TARGET arm-linux-gnueabihf)
set(CMAKE_CXX_COMPILER_TARGET arm-linux-gnueabihf)
else()
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
endif()

envoption(ROOTFS_DIR ${ROOTFS_AARCH64})
# where is the target RootFS
if(DEFINED ENV{ROOTFS_DIR})
set(ROOTFS_DIR $ENV{ROOTFS_DIR})
else()
set(ROOTFS_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../../../tools/cross/rootfs/aarch64")
endif()
if(NOT EXISTS "${ROOTFS_DIR}/lib/aarch64-linux-gnu")
message(FATAL_ERROR "Please prepare RootFS for AARCH64")
endif()
Expand Down
56 changes: 0 additions & 56 deletions infra/nnfw/cmake/buildtool/cross/toolchain_aarch64-tizen.cmake

This file was deleted.

23 changes: 15 additions & 8 deletions infra/nnfw/cmake/buildtool/cross/toolchain_armv7l-linux.cmake
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
#
# config for arm-linux
#
include(CMakeForceCompiler)

# Set CMAKE_SYSTEM_NAME to notify to cmake that we are cross compiling
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR armv7l)

set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++)
if(DEFINED ENV{USE_CLANG} AND "$ENV{USE_CLANG}" STREQUAL "1")
set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)
set(CMAKE_C_COMPILER_TARGET arm-linux-gnueabihf)
set(CMAKE_CXX_COMPILER_TARGET arm-linux-gnueabihf)
else()
set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++)
endif()

# where is the target environment
set(NNAS_PROJECT_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../../..")
set(ROOTFS_ARM "${NNAS_PROJECT_SOURCE_DIR}/tools/cross/rootfs/arm")
include("${NNAS_PROJECT_SOURCE_DIR}/infra/cmake/modules/OptionTools.cmake")

envoption(ROOTFS_DIR ${ROOTFS_ARM})
if(DEFINED ENV{ROOTFS_DIR})
set(ROOTFS_DIR $ENV{ROOTFS_DIR})
else()
set(ROOTFS_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../../../tools/cross/rootfs/arm")
endif()
if(NOT EXISTS "${ROOTFS_DIR}/lib/arm-linux-gnueabihf")
message(FATAL_ERROR "Please prepare RootFS for ARM")
endif()
Expand Down

0 comments on commit 0889d96

Please sign in to comment.