summaryrefslogtreecommitdiff
path: root/infra/nnfw/cmake/buildtool
diff options
context:
space:
mode:
Diffstat (limited to 'infra/nnfw/cmake/buildtool')
-rw-r--r--infra/nnfw/cmake/buildtool/config/config_aarch64-android.cmake9
-rw-r--r--infra/nnfw/cmake/buildtool/config/config_aarch64-linux.cmake12
-rw-r--r--infra/nnfw/cmake/buildtool/config/config_aarch64-tizen.cmake13
-rw-r--r--infra/nnfw/cmake/buildtool/config/config_armv7l-linux.cmake18
-rw-r--r--infra/nnfw/cmake/buildtool/config/config_armv7l-tizen.cmake18
-rw-r--r--infra/nnfw/cmake/buildtool/config/config_linux.cmake21
-rw-r--r--infra/nnfw/cmake/buildtool/config/config_x86_64-linux.cmake12
-rw-r--r--infra/nnfw/cmake/buildtool/cross/toolchain_aarch64-android.cmake25
-rw-r--r--infra/nnfw/cmake/buildtool/cross/toolchain_aarch64-linux.cmake39
-rw-r--r--infra/nnfw/cmake/buildtool/cross/toolchain_aarch64-tizen.cmake62
-rw-r--r--infra/nnfw/cmake/buildtool/cross/toolchain_armv7l-linux.cmake39
-rw-r--r--infra/nnfw/cmake/buildtool/cross/toolchain_armv7l-tizen.cmake66
12 files changed, 334 insertions, 0 deletions
diff --git a/infra/nnfw/cmake/buildtool/config/config_aarch64-android.cmake b/infra/nnfw/cmake/buildtool/config/config_aarch64-android.cmake
new file mode 100644
index 000000000..e0c81dee7
--- /dev/null
+++ b/infra/nnfw/cmake/buildtool/config/config_aarch64-android.cmake
@@ -0,0 +1,9 @@
+include("cmake/buildtool/config/config_linux.cmake")
+
+# On Android, pthread is contained in bionic(libc)
+set(LIB_PTHREAD "")
+
+# SIMD for aarch64
+set(FLAGS_COMMON ${FLAGS_COMMON}
+ "-ftree-vectorize"
+ )
diff --git a/infra/nnfw/cmake/buildtool/config/config_aarch64-linux.cmake b/infra/nnfw/cmake/buildtool/config/config_aarch64-linux.cmake
new file mode 100644
index 000000000..f859bbfe5
--- /dev/null
+++ b/infra/nnfw/cmake/buildtool/config/config_aarch64-linux.cmake
@@ -0,0 +1,12 @@
+#
+# aarch64 linux compile options
+#
+
+message(STATUS "Building for AARCH64 Linux")
+
+# include linux common
+include("cmake/buildtool/config/config_linux.cmake")
+
+# addition for aarch64-linux
+set(FLAGS_COMMON ${FLAGS_COMMON}
+ )
diff --git a/infra/nnfw/cmake/buildtool/config/config_aarch64-tizen.cmake b/infra/nnfw/cmake/buildtool/config/config_aarch64-tizen.cmake
new file mode 100644
index 000000000..fa1e8b078
--- /dev/null
+++ b/infra/nnfw/cmake/buildtool/config/config_aarch64-tizen.cmake
@@ -0,0 +1,13 @@
+#
+# aarch64 tizen compile options
+#
+
+message(STATUS "Building for AARCH64 Tizen")
+
+# TODO : add and use option_tizen if something uncommon comes up
+# include linux common
+include("cmake/buildtool/config/config_linux.cmake")
+
+# addition for aarch64-tizen
+set(FLAGS_COMMON ${FLAGS_COMMON}
+ )
diff --git a/infra/nnfw/cmake/buildtool/config/config_armv7l-linux.cmake b/infra/nnfw/cmake/buildtool/config/config_armv7l-linux.cmake
new file mode 100644
index 000000000..6d6459f0f
--- /dev/null
+++ b/infra/nnfw/cmake/buildtool/config/config_armv7l-linux.cmake
@@ -0,0 +1,18 @@
+#
+# armv7l linux compile options
+#
+
+message(STATUS "Building for ARMv7l Linux")
+
+# include linux common
+include("cmake/buildtool/config/config_linux.cmake")
+
+# addition for arm-linux
+set(FLAGS_COMMON ${FLAGS_COMMON}
+ "-mcpu=cortex-a7"
+ "-mfloat-abi=hard"
+ "-mfpu=neon-vfpv4"
+ "-funsafe-math-optimizations"
+ "-ftree-vectorize"
+ "-mfp16-format=ieee"
+ )
diff --git a/infra/nnfw/cmake/buildtool/config/config_armv7l-tizen.cmake b/infra/nnfw/cmake/buildtool/config/config_armv7l-tizen.cmake
new file mode 100644
index 000000000..a5dae2027
--- /dev/null
+++ b/infra/nnfw/cmake/buildtool/config/config_armv7l-tizen.cmake
@@ -0,0 +1,18 @@
+#
+# armv7l tizen compile options
+#
+
+message(STATUS "Building for ARMv7l(softfp) Tizen")
+
+# TODO : add and use option_tizen if something uncommon comes up
+# include linux common
+include("cmake/buildtool/config/config_linux.cmake")
+
+# addition for arm-linux
+set(FLAGS_COMMON ${FLAGS_COMMON}
+ "-mtune=cortex-a8"
+ "-mfloat-abi=softfp"
+ "-mfpu=neon-vfpv4"
+ "-funsafe-math-optimizations"
+ "-ftree-vectorize"
+ )
diff --git a/infra/nnfw/cmake/buildtool/config/config_linux.cmake b/infra/nnfw/cmake/buildtool/config/config_linux.cmake
new file mode 100644
index 000000000..86dd0f217
--- /dev/null
+++ b/infra/nnfw/cmake/buildtool/config/config_linux.cmake
@@ -0,0 +1,21 @@
+#
+# linux common compile options
+#
+
+# remove warning from arm cl
+# https://github.com/ARM-software/ComputeLibrary/issues/330
+set(GCC_VERSION_DISABLE_WARNING 6.0)
+if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER GCC_VERSION_DISABLE_WARNING)
+ message(STATUS "GCC version higher than ${GCC_VERSION_DISABLE_WARNING}")
+ set(FLAGS_CXXONLY ${FLAGS_CXXONLY}
+ "-Wno-ignored-attributes"
+ )
+endif()
+
+# Disable annoying ABI compatibility warning.
+if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
+ list(APPEND FLAGS_CXXONLY "-Wno-psabi")
+endif()
+
+# lib pthread as a variable (pthread must be disabled on android)
+set(LIB_PTHREAD pthread)
diff --git a/infra/nnfw/cmake/buildtool/config/config_x86_64-linux.cmake b/infra/nnfw/cmake/buildtool/config/config_x86_64-linux.cmake
new file mode 100644
index 000000000..528e48396
--- /dev/null
+++ b/infra/nnfw/cmake/buildtool/config/config_x86_64-linux.cmake
@@ -0,0 +1,12 @@
+#
+# x86_64 linux compile options
+#
+message(STATUS "Building for x86-64 Linux")
+
+# include linux common
+include("cmake/buildtool/config/config_linux.cmake")
+
+# SIMD for x86
+set(FLAGS_COMMON ${FLAGS_COMMON}
+ "-msse4"
+ )
diff --git a/infra/nnfw/cmake/buildtool/cross/toolchain_aarch64-android.cmake b/infra/nnfw/cmake/buildtool/cross/toolchain_aarch64-android.cmake
new file mode 100644
index 000000000..2b2792a6a
--- /dev/null
+++ b/infra/nnfw/cmake/buildtool/cross/toolchain_aarch64-android.cmake
@@ -0,0 +1,25 @@
+# A workaround for accessing to NDK_DIR. This works since Env Vars are always accessible
+# while cache variables are not
+if (NDK_DIR)
+ set(ENV{_NDK_DIR} "${NDK_DIR}")
+else (NDK_DIR)
+ set(NDK_DIR "$ENV{_NDK_DIR}")
+endif (NDK_DIR)
+
+if(NOT DEFINED NDK_DIR)
+ message(FATAL_ERROR "NDK_DIR should be specified via cmake argument")
+endif(NOT DEFINED NDK_DIR)
+
+set(ANDROID_ABI arm64-v8a)
+set(ANDROID_PLATFORM android-27)
+
+# Find package in the host. `nnfw_find_package` won't work without this
+set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE NEVER)
+# Find library in the host. Necessary for `add_library` searching in `out/lib` dir.
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
+
+# Use the toolchain file that NDK provides
+include(${NDK_DIR}/build/cmake/android.toolchain.cmake)
+
+set(TARGET_OS "android")
+set(TARGET_ARCH "aarch64")
diff --git a/infra/nnfw/cmake/buildtool/cross/toolchain_aarch64-linux.cmake b/infra/nnfw/cmake/buildtool/cross/toolchain_aarch64-linux.cmake
new file mode 100644
index 000000000..3356aa72d
--- /dev/null
+++ b/infra/nnfw/cmake/buildtool/cross/toolchain_aarch64-linux.cmake
@@ -0,0 +1,39 @@
+#
+# config for aarch64-linux
+#
+include(CMakeForceCompiler)
+
+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")
+
+envoption(ROOTFS_DIR ${ROOTFS_AARCH64})
+if(NOT EXISTS "${ROOTFS_DIR}/lib/aarch64-linux-gnu")
+ message(FATAL_ERROR "Please prepare RootFS for AARCH64")
+endif()
+
+set(CMAKE_SYSROOT ${ROOTFS_DIR})
+set(CMAKE_FIND_ROOT_PATH ${ROOTFS_DIR})
+set(CMAKE_SHARED_LINKER_FLAGS
+ "${CMAKE_SHARED_LINKER_FLAGS} --sysroot=${ROOTFS_DIR}"
+ CACHE INTERNAL "" FORCE)
+set(CMAKE_EXE_LINKER_FLAGS
+ "${CMAKE_EXE_LINKER_FLAGS} --sysroot=${ROOTFS_DIR}"
+ CACHE INTERNAL "" FORCE)
+
+# search for programs in the build host directories
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+
+# for libraries and headers in the target directories
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+
+# Set cache variable to ignore try-run error by find_package(Threads REQUIRED) on cross build
+set(THREADS_PTHREAD_ARG "2" CACHE STRING "Result from TRY_RUN" FORCE)
diff --git a/infra/nnfw/cmake/buildtool/cross/toolchain_aarch64-tizen.cmake b/infra/nnfw/cmake/buildtool/cross/toolchain_aarch64-tizen.cmake
new file mode 100644
index 000000000..4d5d7ac56
--- /dev/null
+++ b/infra/nnfw/cmake/buildtool/cross/toolchain_aarch64-tizen.cmake
@@ -0,0 +1,62 @@
+#
+# config for aarch64-linux
+#
+include(CMakeForceCompiler)
+
+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++)
+
+set(TIZEN_TOOLCHAIN "aarch64-tizen-linux-gnu/6.2.1")
+
+# 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")
+
+envoption(ROOTFS_DIR ${ROOTFS_AARCH64})
+if(NOT EXISTS "${ROOTFS_DIR}/usr/lib64/gcc/${TIZEN_TOOLCHAIN}")
+ message(FATAL_ERROR "Please prepare RootFS for tizen aarch64")
+endif()
+
+set(CMAKE_SYSROOT ${ROOTFS_DIR})
+set(CMAKE_FIND_ROOT_PATH ${ROOTFS_DIR})
+set(CMAKE_SHARED_LINKER_FLAGS
+ "${CMAKE_SHARED_LINKER_FLAGS} --sysroot=${ROOTFS_DIR}"
+ CACHE INTERNAL "" FORCE)
+set(CMAKE_EXE_LINKER_FLAGS
+ "${CMAKE_EXE_LINKER_FLAGS} --sysroot=${ROOTFS_DIR}"
+ CACHE INTERNAL "" FORCE)
+
+# search for programs in the build host directories
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+
+# for libraries and headers in the target directories
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+
+# Set cache variable to ignore try-run error by find_package(Threads REQUIRED) on cross build
+set(THREADS_PTHREAD_ARG "2" CACHE STRING "Result from TRY_RUN" FORCE)
+
+add_compile_options(--sysroot=${ROOTFS_DIR})
+
+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --sysroot=${ROOTFS_DIR}")
+
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --sysroot=${ROOTFS_DIR}")
+
+include_directories(SYSTEM ${ROOTFS_DIR}/usr/lib64/gcc/${TIZEN_TOOLCHAIN}/include/c++/)
+include_directories(SYSTEM ${ROOTFS_DIR}/usr/lib64/gcc/${TIZEN_TOOLCHAIN}/include/c++/aarch64-tizen-linux-gnu)
+add_compile_options(-Wno-deprecated-declarations) # compile-time option
+add_compile_options(-D__extern_always_inline=inline) # compile-time option
+
+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -B${ROOTFS_DIR}/usr/lib64/gcc/${TIZEN_TOOLCHAIN}")
+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${ROOTFS_DIR}/lib64")
+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${ROOTFS_DIR}/usr/lib64")
+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${ROOTFS_DIR}/usr/lib64/gcc/${TIZEN_TOOLCHAIN}")
+
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -B${ROOTFS_DIR}/usr/lib64/gcc/${TIZEN_TOOLCHAIN}")
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${ROOTFS_DIR}/lib64")
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${ROOTFS_DIR}/usr/lib64")
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${ROOTFS_DIR}/usr/lib64/gcc/${TIZEN_TOOLCHAIN}")
diff --git a/infra/nnfw/cmake/buildtool/cross/toolchain_armv7l-linux.cmake b/infra/nnfw/cmake/buildtool/cross/toolchain_armv7l-linux.cmake
new file mode 100644
index 000000000..8f2cb6735
--- /dev/null
+++ b/infra/nnfw/cmake/buildtool/cross/toolchain_armv7l-linux.cmake
@@ -0,0 +1,39 @@
+#
+# config for arm-linux
+#
+include(CMakeForceCompiler)
+
+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++)
+
+# 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(NOT EXISTS "${ROOTFS_DIR}/lib/arm-linux-gnueabihf")
+ message(FATAL_ERROR "Please prepare RootFS for ARM")
+endif()
+
+set(CMAKE_SYSROOT ${ROOTFS_DIR})
+set(CMAKE_FIND_ROOT_PATH ${ROOTFS_DIR})
+set(CMAKE_SHARED_LINKER_FLAGS
+ "${CMAKE_SHARED_LINKER_FLAGS} --sysroot=${ROOTFS_DIR}"
+ CACHE INTERNAL "" FORCE)
+set(CMAKE_EXE_LINKER_FLAGS
+ "${CMAKE_EXE_LINKER_FLAGS} --sysroot=${ROOTFS_DIR}"
+ CACHE INTERNAL "" FORCE)
+
+# search for programs in the build host directories
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+
+# for libraries and headers in the target directories
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+
+# Set cache variable to ignore try-run error by find_package(Threads REQUIRED) on cross build
+set(THREADS_PTHREAD_ARG "2" CACHE STRING "Result from TRY_RUN" FORCE)
diff --git a/infra/nnfw/cmake/buildtool/cross/toolchain_armv7l-tizen.cmake b/infra/nnfw/cmake/buildtool/cross/toolchain_armv7l-tizen.cmake
new file mode 100644
index 000000000..72513cdc1
--- /dev/null
+++ b/infra/nnfw/cmake/buildtool/cross/toolchain_armv7l-tizen.cmake
@@ -0,0 +1,66 @@
+#
+# config for arm-linux
+#
+include(CMakeForceCompiler)
+
+set(CMAKE_SYSTEM_NAME Linux)
+set(CMAKE_SYSTEM_PROCESSOR armv7l)
+
+set(CMAKE_C_COMPILER arm-linux-gnueabi-gcc)
+set(CMAKE_CXX_COMPILER arm-linux-gnueabi-g++)
+
+set(TIZEN_TOOLCHAIN "armv7l-tizen-linux-gnueabi/6.2.1")
+
+# where is the target environment
+set(NNAS_PROJECT_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../../..")
+set(ROOTFS_ARM "${NNAS_PROJECT_SOURCE_DIR}/tools/cross/rootfs/armel")
+include("${NNAS_PROJECT_SOURCE_DIR}/infra/cmake/modules/OptionTools.cmake")
+
+envoption(ROOTFS_DIR ${ROOTFS_ARM})
+if(NOT EXISTS "${ROOTFS_DIR}/usr/lib/gcc/${TIZEN_TOOLCHAIN}")
+ message(FATAL_ERROR "Please prepare RootFS for tizen ARM softfp")
+endif()
+
+set(CMAKE_SYSROOT ${ROOTFS_DIR})
+set(CMAKE_FIND_ROOT_PATH ${ROOTFS_DIR})
+set(CMAKE_SHARED_LINKER_FLAGS
+ "${CMAKE_SHARED_LINKER_FLAGS} --sysroot=${ROOTFS_DIR}"
+ CACHE INTERNAL "" FORCE)
+set(CMAKE_EXE_LINKER_FLAGS
+ "${CMAKE_EXE_LINKER_FLAGS} --sysroot=${ROOTFS_DIR}"
+ CACHE INTERNAL "" FORCE)
+
+# search for programs in the build host directories
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+
+# for libraries and headers in the target directories
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+
+# Set cache variable to ignore try-run error by find_package(Threads REQUIRED) on cross build
+set(THREADS_PTHREAD_ARG "2" CACHE STRING "Result from TRY_RUN" FORCE)
+
+
+add_compile_options(-mthumb)
+add_compile_options(-mfpu=neon-vfpv4)
+add_compile_options(-mfloat-abi=softfp)
+add_compile_options(--sysroot=${ROOTFS_DIR})
+
+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --sysroot=${ROOTFS_DIR}")
+
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --sysroot=${ROOTFS_DIR}")
+
+include_directories(SYSTEM ${ROOTFS_DIR}/usr/lib/gcc/${TIZEN_TOOLCHAIN}/include/c++/)
+include_directories(SYSTEM ${ROOTFS_DIR}/usr/lib/gcc/${TIZEN_TOOLCHAIN}/include/c++/armv7l-tizen-linux-gnueabi)
+add_compile_options(-Wno-deprecated-declarations) # compile-time option
+add_compile_options(-D__extern_always_inline=inline) # compile-time option
+
+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -B${ROOTFS_DIR}/usr/lib/gcc/${TIZEN_TOOLCHAIN}")
+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${ROOTFS_DIR}/lib")
+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${ROOTFS_DIR}/usr/lib")
+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${ROOTFS_DIR}/usr/lib/gcc/${TIZEN_TOOLCHAIN}")
+
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -B${ROOTFS_DIR}/usr/lib/gcc/${TIZEN_TOOLCHAIN}")
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${ROOTFS_DIR}/lib")
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${ROOTFS_DIR}/usr/lib")
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${ROOTFS_DIR}/usr/lib/gcc/${TIZEN_TOOLCHAIN}")