summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake')
-rw-r--r--cmake/config/config_aarch64-linux.cmake33
-rw-r--r--cmake/config/config_aarch64-tizen.cmake56
-rw-r--r--cmake/config/config_arm64-android.cmake44
-rw-r--r--cmake/config/config_armv7l-linux.cmake33
-rw-r--r--cmake/config/config_armv7l-tizen.cmake61
-rw-r--r--cmake/config/config_x86_64-linux.cmake7
-rw-r--r--cmake/option/option_aarch64-linux.cmake16
-rw-r--r--cmake/option/option_aarch64-tizen.cmake15
-rw-r--r--cmake/option/option_arm64-android.cmake4
-rw-r--r--cmake/option/option_armv7l-linux.cmake21
-rw-r--r--cmake/option/option_armv7l-tizen.cmake20
-rw-r--r--cmake/option/option_linux.cmake9
-rw-r--r--cmake/option/option_x86_64-linux.cmake12
13 files changed, 331 insertions, 0 deletions
diff --git a/cmake/config/config_aarch64-linux.cmake b/cmake/config/config_aarch64-linux.cmake
new file mode 100644
index 000000000..b13a8b02f
--- /dev/null
+++ b/cmake/config/config_aarch64-linux.cmake
@@ -0,0 +1,33 @@
+#
+# config for aarch64-linux
+#
+include(CMakeForceCompiler)
+
+set(CMAKE_SYSTEM_NAME Linux)
+set(CMAKE_SYSTEM_PROCESSOR aarch64)
+
+set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc-5)
+set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++-5)
+
+# where is the target environment
+set(ROOTFS_ARM64 $ENV{ROOTFS_ARM64})
+if(NOT EXISTS "${ROOTFS_ARM64}/lib/aarch64-linux-gnu")
+ set(ROOTFS_ARM64 "${CMAKE_SOURCE_DIR}/tools/cross/rootfs/arm64")
+endif()
+
+set(CMAKE_SYSROOT ${ROOTFS_ARM64})
+set(CMAKE_FIND_ROOT_PATH ${ROOTFS_ARM64})
+set(CMAKE_SHARED_LINKER_FLAGS
+ "${CMAKE_SHARED_LINKER_FLAGS} --sysroot=${ROOTFS_ARM64}"
+ CACHE INTERNAL "" FORCE)
+set(CMAKE_EXE_LINKER_FLAGS
+ "${CMAKE_EXE_LINKER_FLAGS} --sysroot=${ROOTFS_ARM64}"
+ 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(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
diff --git a/cmake/config/config_aarch64-tizen.cmake b/cmake/config/config_aarch64-tizen.cmake
new file mode 100644
index 000000000..e76ad219b
--- /dev/null
+++ b/cmake/config/config_aarch64-tizen.cmake
@@ -0,0 +1,56 @@
+#
+# config for aarch64-linux
+#
+include(CMakeForceCompiler)
+
+set(CMAKE_SYSTEM_NAME Linux)
+set(CMAKE_SYSTEM_PROCESSOR aarch64)
+
+set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc-5)
+set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++-5)
+
+set(TIZEN_TOOLCHAIN "aarch64-tizen-linux-gnu/6.2.1")
+
+# where is the target environment
+set(ROOTFS_ARM64 $ENV{ROOTFS_ARM64})
+if(NOT EXISTS "${ROOTFS_ARM64}/usr/lib64/gcc/${TIZEN_TOOLCHAIN}")
+ set(ROOTFS_ARM64 "${CMAKE_SOURCE_DIR}/tools/cross/rootfs/arm64")
+endif()
+
+set(CMAKE_SYSROOT ${ROOTFS_ARM64})
+set(CMAKE_FIND_ROOT_PATH ${ROOTFS_ARM64})
+set(CMAKE_SHARED_LINKER_FLAGS
+ "${CMAKE_SHARED_LINKER_FLAGS} --sysroot=${ROOTFS_ARM64}"
+ CACHE INTERNAL "" FORCE)
+set(CMAKE_EXE_LINKER_FLAGS
+ "${CMAKE_EXE_LINKER_FLAGS} --sysroot=${ROOTFS_ARM64}"
+ 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(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
+
+add_compile_options(--sysroot=${ROOTFS_ARM64})
+
+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --sysroot=${ROOTFS_ARM64}")
+
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --sysroot=${ROOTFS_ARM64}")
+
+include_directories(SYSTEM ${ROOTFS_ARM64}/usr/lib64/gcc/${TIZEN_TOOLCHAIN}/include/c++/)
+include_directories(SYSTEM ${ROOTFS_ARM64}/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_ARM64}/usr/lib64/gcc/${TIZEN_TOOLCHAIN}")
+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${ROOTFS_ARM64}/lib64")
+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${ROOTFS_ARM64}/usr/lib64")
+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${ROOTFS_ARM64}/usr/lib64/gcc/${TIZEN_TOOLCHAIN}")
+
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -B${ROOTFS_ARM64}/usr/lib64/gcc/${TIZEN_TOOLCHAIN}")
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${ROOTFS_ARM64}/lib64")
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${ROOTFS_ARM64}/usr/lib64")
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${ROOTFS_ARM64}/usr/lib64/gcc/${TIZEN_TOOLCHAIN}")
diff --git a/cmake/config/config_arm64-android.cmake b/cmake/config/config_arm64-android.cmake
new file mode 100644
index 000000000..1c096b583
--- /dev/null
+++ b/cmake/config/config_arm64-android.cmake
@@ -0,0 +1,44 @@
+set(ANDROID_STANDALONE $ENV{ROOTFS_ARM64})
+set(CROSS_NDK_TOOLCHAIN ${ANDROID_STANDALONE}/bin)
+set(CROSS_ROOTFS ${ANDROID_STANDALONE}/sysroot)
+
+set(CMAKE_SYSTEM_NAME Linux)
+set(CMAKE_SYSTEM_VERSION 1)
+set(CMAKE_SYSTEM_PROCESSOR aarch64)
+
+## Specify the toolchain
+set(TOOLCHAIN "aarch64-linux-android")
+set(CMAKE_PREFIX_PATH ${CROSS_NDK_TOOLCHAIN})
+set(TOOLCHAIN_PREFIX ${TOOLCHAIN}-)
+
+find_program(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}clang)
+find_program(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}clang++)
+find_program(CMAKE_ASM_COMPILER ${TOOLCHAIN_PREFIX}clang)
+find_program(CMAKE_AR ${TOOLCHAIN_PREFIX}ar)
+find_program(CMAKE_LD ${TOOLCHAIN_PREFIX}ar)
+find_program(CMAKE_OBJCOPY ${TOOLCHAIN_PREFIX}objcopy)
+find_program(CMAKE_OBJDUMP ${TOOLCHAIN_PREFIX}objdump)
+
+add_compile_options(--sysroot=${CROSS_ROOTFS})
+add_compile_options(-fPIE)
+
+## Needed for Android or bionic specific conditionals
+#add_compile_options(-D__ANDROID__)
+#add_compile_options(-D__BIONIC__)
+
+## NOTE Not sure this is safe. This may cause side effects.
+## Without this, it cannot find `std::stol`, `std::stoi` and so on, with android toolchain
+add_compile_options(-D_GLIBCXX_USE_C99=1)
+
+set(CROSS_LINK_FLAGS "${CROSS_LINK_FLAGS} -B${CROSS_ROOTFS}/usr/lib/gcc/${TOOLCHAIN}")
+set(CROSS_LINK_FLAGS "${CROSS_LINK_FLAGS} -L${CROSS_ROOTFS}/lib/${TOOLCHAIN}")
+set(CROSS_LINK_FLAGS "${CROSS_LINK_FLAGS} --sysroot=${CROSS_ROOTFS}")
+set(CROSS_LINK_FLAGS "${CROSS_LINK_FLAGS} -fPIE -pie")
+
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CROSS_LINK_FLAGS}" CACHE STRING "" FORCE)
+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CROSS_LINK_FLAGS}" CACHE STRING "" FORCE)
+set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${CROSS_LINK_FLAGS}" CACHE STRING "" FORCE)
+
+set(CMAKE_FIND_ROOT_PATH "${CROSS_ROOTFS}")
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
diff --git a/cmake/config/config_armv7l-linux.cmake b/cmake/config/config_armv7l-linux.cmake
new file mode 100644
index 000000000..01d3df937
--- /dev/null
+++ b/cmake/config/config_armv7l-linux.cmake
@@ -0,0 +1,33 @@
+#
+# 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(ROOTFS_ARM $ENV{ROOTFS_ARM})
+if(NOT EXISTS "${ROOTFS_ARM}/lib/arm-linux-gnueabihf")
+ set(ROOTFS_ARM "${CMAKE_SOURCE_DIR}/tools/cross/rootfs/arm")
+endif()
+
+set(CMAKE_SYSROOT ${ROOTFS_ARM})
+set(CMAKE_FIND_ROOT_PATH ${ROOTFS_ARM})
+set(CMAKE_SHARED_LINKER_FLAGS
+ "${CMAKE_SHARED_LINKER_FLAGS} --sysroot=${ROOTFS_ARM}"
+ CACHE INTERNAL "" FORCE)
+set(CMAKE_EXE_LINKER_FLAGS
+ "${CMAKE_EXE_LINKER_FLAGS} --sysroot=${ROOTFS_ARM}"
+ 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(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
diff --git a/cmake/config/config_armv7l-tizen.cmake b/cmake/config/config_armv7l-tizen.cmake
new file mode 100644
index 000000000..3d49492cd
--- /dev/null
+++ b/cmake/config/config_armv7l-tizen.cmake
@@ -0,0 +1,61 @@
+#
+# config for arm-linux
+#
+include(CMakeForceCompiler)
+
+set(CMAKE_SYSTEM_NAME Linux)
+set(CMAKE_SYSTEM_PROCESSOR armv7l)
+
+set(CMAKE_C_COMPILER arm-linux-gnueabi-gcc-5)
+set(CMAKE_CXX_COMPILER arm-linux-gnueabi-g++-5)
+
+set(TIZEN_TOOLCHAIN "armv7l-tizen-linux-gnueabi/6.2.1")
+
+# where is the target environment
+set(ROOTFS_ARM $ENV{ROOTFS_ARM})
+if(NOT EXISTS "${ROOTFS_ARM}/usr/lib/gcc/${TIZEN_TOOLCHAIN}")
+ set(ROOTFS_ARM "${CMAKE_SOURCE_DIR}/tools/cross/rootfs/armel")
+endif()
+
+set(CMAKE_SYSROOT ${ROOTFS_ARM})
+set(CMAKE_FIND_ROOT_PATH ${ROOTFS_ARM})
+set(CMAKE_SHARED_LINKER_FLAGS
+ "${CMAKE_SHARED_LINKER_FLAGS} --sysroot=${ROOTFS_ARM}"
+ CACHE INTERNAL "" FORCE)
+set(CMAKE_EXE_LINKER_FLAGS
+ "${CMAKE_EXE_LINKER_FLAGS} --sysroot=${ROOTFS_ARM}"
+ 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(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
+
+
+
+add_compile_options(-mthumb)
+add_compile_options(-mfpu=neon-vfpv4)
+add_compile_options(-mfloat-abi=softfp)
+add_compile_options(--sysroot=${ROOTFS_ARM})
+
+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --sysroot=${ROOTFS_ARM}")
+
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --sysroot=${ROOTFS_ARM}")
+
+include_directories(SYSTEM ${ROOTFS_ARM}/usr/lib/gcc/${TIZEN_TOOLCHAIN}/include/c++/)
+include_directories(SYSTEM ${ROOTFS_ARM}/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_ARM}/usr/lib/gcc/${TIZEN_TOOLCHAIN}")
+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${ROOTFS_ARM}/lib")
+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${ROOTFS_ARM}/usr/lib")
+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${ROOTFS_ARM}/usr/lib/gcc/${TIZEN_TOOLCHAIN}")
+
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -B${ROOTFS_ARM}/usr/lib/gcc/${TIZEN_TOOLCHAIN}")
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${ROOTFS_ARM}/lib")
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${ROOTFS_ARM}/usr/lib")
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${ROOTFS_ARM}/usr/lib/gcc/${TIZEN_TOOLCHAIN}")
diff --git a/cmake/config/config_x86_64-linux.cmake b/cmake/config/config_x86_64-linux.cmake
new file mode 100644
index 000000000..3dee8766c
--- /dev/null
+++ b/cmake/config/config_x86_64-linux.cmake
@@ -0,0 +1,7 @@
+#
+# config for x86_64-linux
+#
+include(CMakeForceCompiler)
+
+set(CMAKE_SYSTEM_NAME Linux)
+set(CMAKE_SYSTEM_PROCESSOR x86_64)
diff --git a/cmake/option/option_aarch64-linux.cmake b/cmake/option/option_aarch64-linux.cmake
new file mode 100644
index 000000000..fa5c9205c
--- /dev/null
+++ b/cmake/option/option_aarch64-linux.cmake
@@ -0,0 +1,16 @@
+#
+# aarch64 linux compile options
+#
+
+message(STATUS "Building for AARCH64 Linux")
+
+# include linux common
+include("cmake/option/option_linux.cmake")
+
+if(NOT EXISTS "${ROOTFS_ARM64}/lib/aarch64-linux-gnu")
+ message(FATAL_ERROR "Please prepare RootFS for ARM64")
+endif()
+
+# addition for aarch64-linux
+set(FLAGS_COMMON ${FLAGS_COMMON}
+ )
diff --git a/cmake/option/option_aarch64-tizen.cmake b/cmake/option/option_aarch64-tizen.cmake
new file mode 100644
index 000000000..5e37f35a9
--- /dev/null
+++ b/cmake/option/option_aarch64-tizen.cmake
@@ -0,0 +1,15 @@
+#
+# 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/option/option_linux.cmake")
+
+# TODO : support rootfs setting for tizen cross-build
+
+# addition for aarch64-tizen
+set(FLAGS_COMMON ${FLAGS_COMMON}
+ )
diff --git a/cmake/option/option_arm64-android.cmake b/cmake/option/option_arm64-android.cmake
new file mode 100644
index 000000000..42e504afe
--- /dev/null
+++ b/cmake/option/option_arm64-android.cmake
@@ -0,0 +1,4 @@
+include("cmake/option/option_linux.cmake")
+
+# On Android, pthread is contained in bionic(libc)
+set(LIB_PTHREAD "")
diff --git a/cmake/option/option_armv7l-linux.cmake b/cmake/option/option_armv7l-linux.cmake
new file mode 100644
index 000000000..d4505ce1b
--- /dev/null
+++ b/cmake/option/option_armv7l-linux.cmake
@@ -0,0 +1,21 @@
+#
+# armv7l linux compile options
+#
+
+message(STATUS "Building for ARMv7l Linux")
+
+# include linux common
+include("cmake/option/option_linux.cmake")
+
+if(NOT EXISTS "${ROOTFS_ARM}/lib/arm-linux-gnueabihf")
+ message(FATAL_ERROR "Please prepare RootFS for ARM")
+endif()
+
+# addition for arm-linux
+set(FLAGS_COMMON ${FLAGS_COMMON}
+ "-mcpu=cortex-a7"
+ "-mfloat-abi=hard"
+ "-mfpu=neon-vfpv4"
+ "-funsafe-math-optimizations"
+ "-ftree-vectorize"
+ )
diff --git a/cmake/option/option_armv7l-tizen.cmake b/cmake/option/option_armv7l-tizen.cmake
new file mode 100644
index 000000000..6040eb6b8
--- /dev/null
+++ b/cmake/option/option_armv7l-tizen.cmake
@@ -0,0 +1,20 @@
+#
+# 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/option/option_linux.cmake")
+
+# TODO : support rootfs setting for tizen cross-build
+
+# addition for arm-linux
+set(FLAGS_COMMON ${FLAGS_COMMON}
+ "-mcpu=cortex-a8"
+ "-mfloat-abi=softfp"
+ "-mfpu=neon-vfpv4"
+ "-funsafe-math-optimizations"
+ "-ftree-vectorize"
+ )
diff --git a/cmake/option/option_linux.cmake b/cmake/option/option_linux.cmake
new file mode 100644
index 000000000..ea533ec36
--- /dev/null
+++ b/cmake/option/option_linux.cmake
@@ -0,0 +1,9 @@
+#
+# linux common compile options
+#
+
+# flags for build type: debug, release
+set(CMAKE_C_FLAGS_DEBUG "-O0 -g -DDEBUG")
+set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -DDEBUG")
+set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
+set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
diff --git a/cmake/option/option_x86_64-linux.cmake b/cmake/option/option_x86_64-linux.cmake
new file mode 100644
index 000000000..6f4d0ebfc
--- /dev/null
+++ b/cmake/option/option_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/option/option_linux.cmake")
+
+# SIMD for x86
+set(FLAGS_COMMON ${FLAGS_COMMON}
+ "-msse4"
+ )