From: Zhongwei Yao Date: Tue, 17 Feb 2015 06:57:23 +0000 (+0800) Subject: Enable building for ARMv7 under GNU Linux. Fix issue #97. X-Git-Tag: v1.2.1~20 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fcc6ffb5c5f48304a2e2330c2969e5e88b92bec0;p=platform%2Fupstream%2Fne10.git Enable building for ARMv7 under GNU Linux. Fix issue #97. Change-Id: Ib8f2bc4b1d5d3b7c6b06648a4699f76e9d243332 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 63412ab..2ab4b08 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,8 +53,26 @@ if((NOT ANDROID_PLATFORM) AND (NOT GNULINUX_PLATFORM) AND (NOT IOS_PLATFORM)) message(FATAL_ERROR "No platform is defined! see CMakeBuilding.txt under doc for details.") endif() +if(DEFINED NE10_ANDROID_TARGET_ARCH) + if(${NE10_ANDROID_TARGET_ARCH} STREQUAL "armv7") + set(NE10_TARGET_ARCH "armv7") + else() + set(NE10_TARGET_ARCH "aarch64") + endif() +endif() + +if(DEFINED NE10_LINUX_TARGET_ARCH) + if(${NE10_LINUX_TARGET_ARCH} STREQUAL "armv7") + set(NE10_TARGET_ARCH "armv7") + else() + set(NE10_TARGET_ARCH "aarch64") + endif() +endif() + +message("-- Target architecture : ${NE10_TARGET_ARCH}") + #select functionalities to be compiled -if(${NE10_ANDROID_TARGET_ARCH} STREQUAL "armv7") +if(${NE10_TARGET_ARCH} STREQUAL "armv7") # Math module has not been optimized for aarch64. option(NE10_ENABLE_MATH "Build math functionalities to NE10" ON) endif() @@ -83,7 +101,7 @@ if(ANDROID_PLATFORM) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --sysroot=${NDK_SYSROOT_PATH} -pie") # Adding cflags for armv7. Aarch64 does not need such flags. - if(${NE10_ANDROID_TARGET_ARCH} STREQUAL "armv7") + if(${NE10_TARGET_ARCH} STREQUAL "armv7") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mthumb-interwork -mthumb -march=armv7-a -mfloat-abi=${FLOAT_ABI} -mfpu=vfp3") if(NE10_ARM_HARD_FLOAT) # "--no-warn-mismatch" is needed for linker to suppress linker error about not all functions use VFP register to pass argument, eg. @@ -99,6 +117,8 @@ if(ANDROID_PLATFORM) ${CMAKE_C_COMPILER} ${CMAKE_CXX_COMPILER} ${CMAKE_ASM_COMPILER}") + message("-- CMAKE_C_FLAGS: + ${CMAKE_C_FLAGS}") elseif(GNULINUX_PLATFORM) #TODO Development has been moved to android, GNULINUX_PLATFORM is not # needed any more. GNULINUX_PLATFORM support needs to be removed. diff --git a/GNUlinux_config.cmake b/GNUlinux_config.cmake index 8343d20..622e78c 100644 --- a/GNUlinux_config.cmake +++ b/GNUlinux_config.cmake @@ -25,11 +25,31 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # +# Usage: +# $ mkdir build && cd build +# $ cmake -DCMAKE_TOOLCHAIN_FILE=path/of/GNUlinux_config.cmake .. +# $ make +# +# Option: +# - Choose target architecture +# Target architecture can be specified by setting NE10_LINUX_TARGET_ARCH to +# armv7 or aarch64 (Not done yet). Defaut is armv7. + set(GNULINUX_PLATFORM ON) +#TODO: add support to AArch64 target set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc) set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++) set(CMAKE_ASM_COMPILER arm-linux-gnueabihf-as) +if(NOT DEFINED ENV{NE10_LINUX_TARGET_ARCH}) + set(NE10_LINUX_TARGET_ARCH "armv7") +else() + if($ENV{NE10_LINUX_TARGET_ARCH} STREQUAL "aarch64") + message(FATAL_ERROR "aarch64 on GNU Linux support has not been done yet.") + endif() + set(NE10_LINUX_TARGET_ARCH $ENV{NE10_LINUX_TARGET_ARCH}) +endif() + find_program(CMAKE_AR NAMES "arm-linux-gnueabihf-ar") mark_as_advanced(CMAKE_AR) find_program(CMAKE_RANLIB NAMES "arm-linux-gnueabihf-ranlib") diff --git a/android/android_config.cmake b/android/android_config.cmake index 6a13ca1..4e95dff 100644 --- a/android/android_config.cmake +++ b/android/android_config.cmake @@ -57,7 +57,6 @@ if(NOT DEFINED ENV{NE10_ANDROID_TARGET_ARCH}) else() set(NE10_ANDROID_TARGET_ARCH $ENV{NE10_ANDROID_TARGET_ARCH}) endif() -message("-- Target architecture : ${NE10_ANDROID_TARGET_ARCH}") if(DEFINED ENV{ANDROID_NDK}) if(NOT DEFINED ENV{ANDROID_API_LEVEL}) diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index 03b571c..58e5c6e 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -120,7 +120,7 @@ if(NE10_ENABLE_MATH) ) # Tell CMake these files need to be compiled with "-mfpu=neon" - if(${NE10_ANDROID_TARGET_ARCH} STREQUAL "armv7") + if(${NE10_TARGET_ARCH} STREQUAL "armv7") foreach(intrinsic_file ${NE10_MATH_INTRINSIC_SRCS}) set_source_files_properties(${intrinsic_file} PROPERTIES COMPILE_FLAGS "-mfpu=neon" ) endforeach(intrinsic_file) @@ -189,7 +189,7 @@ if(NE10_ENABLE_DSP) ) # Tell CMake these files need to be compiled with "-mfpu=neon" - if(${NE10_ANDROID_TARGET_ARCH} STREQUAL "armv7") + if(${NE10_TARGET_ARCH} STREQUAL "armv7") # Following definition is only available under armv7. add_definitions(-DENABLE_NE10_FIR_FLOAT_NEON) add_definitions(-DENABLE_NE10_FIR_DECIMATE_FLOAT_NEON) @@ -263,7 +263,7 @@ if(NE10_ENABLE_IMGPROC) ${PROJECT_SOURCE_DIR}/modules/imgproc/NE10_boxfilter.c ) - if(${NE10_ANDROID_TARGET_ARCH} STREQUAL "armv7") + if(${NE10_TARGET_ARCH} STREQUAL "armv7") # Following definition is only available under armv7. add_definitions(-DENABLE_NE10_IMG_ROTATE_RGBA_NEON) # Add image processing NEON files. @@ -277,7 +277,7 @@ if(NE10_ENABLE_IMGPROC) ${PROJECT_SOURCE_DIR}/modules/imgproc/NE10_boxfilter.neon.c ) # Tell CMake these files need to be compiled with "-mfpu=neon" - if(${NE10_ANDROID_TARGET_ARCH} STREQUAL "armv7") + if(${NE10_TARGET_ARCH} STREQUAL "armv7") foreach(intrinsic_file ${NE10_IMGPROC_INTRINSIC_SRCS}) set_source_files_properties(${intrinsic_file} PROPERTIES COMPILE_FLAGS "-mfpu=neon" ) endforeach(intrinsic_file) @@ -312,7 +312,7 @@ if(NE10_ENABLE_PHYSICS) ${PROJECT_SOURCE_DIR}/modules/physics/NE10_physics.c ) - if(${NE10_ANDROID_TARGET_ARCH} STREQUAL "armv7") + if(${NE10_TARGET_ARCH} STREQUAL "armv7") # Following definition is only available under armv7. add_definitions(-DENABLE_NE10_PHYSICS_COMPUTE_AABB_VEC2F_NEON) add_definitions(-DENABLE_NE10_PHYSICS_RELATIVE_V_VEC2F_NEON) @@ -328,7 +328,7 @@ if(NE10_ENABLE_PHYSICS) ${PROJECT_SOURCE_DIR}/modules/physics/NE10_physics.neon.c ) # Tell CMake these files need to be compiled with "-mfpu=neon" - if(${NE10_ANDROID_TARGET_ARCH} STREQUAL "armv7") + if(${NE10_TARGET_ARCH} STREQUAL "armv7") foreach(intrinsic_file ${NE10_PHYSICS_INTRINSIC_SRCS}) set_source_files_properties(${intrinsic_file} PROPERTIES COMPILE_FLAGS "-mfpu=neon" ) endforeach(intrinsic_file)