Merge pull request #442 from asmorkalov:linux_cross_compile
This commit is contained in:
commit
6ffd5edfb5
29
3rdparty/tbb/CMakeLists.txt
vendored
29
3rdparty/tbb/CMakeLists.txt
vendored
@ -1,8 +1,4 @@
|
||||
#build TBB for Android from source
|
||||
if(NOT ANDROID)
|
||||
message(FATAL_ERROR "The script is designed for Android only!")
|
||||
endif()
|
||||
|
||||
#Cross compile TBB from source
|
||||
project(tbb)
|
||||
|
||||
# 4.1 update 1 - works fine
|
||||
@ -121,9 +117,9 @@ list(APPEND lib_srcs "${tbb_src_dir}/src/rml/client/rml_tbb.cpp")
|
||||
|
||||
add_definitions(-D__TBB_DYNAMIC_LOAD_ENABLED=0 #required
|
||||
-D__TBB_BUILD=1 #required
|
||||
-D__TBB_SURVIVE_THREAD_SWITCH=0 #no cilk on Android ?
|
||||
-DUSE_PTHREAD #required
|
||||
-DTBB_USE_GCC_BUILTINS=1 #required
|
||||
-D__TBB_SURVIVE_THREAD_SWITCH=0 #no cilk support
|
||||
-DUSE_PTHREAD #required for Unix
|
||||
-DTBB_USE_GCC_BUILTINS=1 #required for ARM GCC
|
||||
-DTBB_USE_DEBUG=0 #just to be sure
|
||||
-DTBB_NO_LEGACY=1 #don't need backward compatibility
|
||||
-DDO_ITT_NOTIFY=0 #it seems that we don't need these notifications
|
||||
@ -140,14 +136,24 @@ if(tbb_need_GENERIC_DWORD_LOAD_STORE)
|
||||
set(tbb_need_GENERIC_DWORD_LOAD_STORE ON PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
add_library(tbb STATIC ${lib_srcs} ${lib_hdrs} "${CMAKE_CURRENT_SOURCE_DIR}/android_additional.h" "${CMAKE_CURRENT_SOURCE_DIR}/${tbb_version_file}")
|
||||
set(TBB_SOURCE_FILES ${lib_srcs} ${lib_hdrs})
|
||||
|
||||
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
|
||||
if (NOT ANDROID)
|
||||
set(TBB_SOURCE_FILES ${TBB_SOURCE_FILES} "${CMAKE_CURRENT_SOURCE_DIR}/arm_linux_stub.cpp")
|
||||
endif()
|
||||
set(TBB_SOURCE_FILES ${TBB_SOURCE_FILES} "${CMAKE_CURRENT_SOURCE_DIR}/android_additional.h")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include \"${CMAKE_CURRENT_SOURCE_DIR}/android_additional.h\"")
|
||||
endif()
|
||||
|
||||
set(TBB_SOURCE_FILES ${TBB_SOURCE_FILES} "${CMAKE_CURRENT_SOURCE_DIR}/${tbb_version_file}")
|
||||
|
||||
add_library(tbb ${TBB_SOURCE_FILES})
|
||||
target_link_libraries(tbb c m dl)
|
||||
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef -Wmissing-declarations)
|
||||
string(REPLACE "-Werror=non-virtual-dtor" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include \"${CMAKE_CURRENT_SOURCE_DIR}/android_additional.h\"")
|
||||
|
||||
set_target_properties(tbb
|
||||
PROPERTIES OUTPUT_NAME tbb
|
||||
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
|
||||
@ -164,4 +170,3 @@ endif()
|
||||
|
||||
# get TBB version
|
||||
ocv_parse_header("${tbb_src_dir}/include/tbb/tbb_stddef.h" TBB_VERSION_LINES TBB_VERSION_MAJOR TBB_VERSION_MINOR TBB_INTERFACE_VERSION CACHE)
|
||||
|
||||
|
10
3rdparty/tbb/arm_linux_stub.cpp
vendored
Normal file
10
3rdparty/tbb/arm_linux_stub.cpp
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
#include "tbb/tbb_misc.h"
|
||||
|
||||
namespace tbb {
|
||||
namespace internal {
|
||||
|
||||
void affinity_helper::protect_affinity_mask() {}
|
||||
affinity_helper::~affinity_helper() {}
|
||||
|
||||
}
|
||||
}
|
@ -163,13 +163,13 @@ OCV_OPTION(BUILD_ANDROID_SERVICE "Build OpenCV Manager for Google Play" OFF I
|
||||
OCV_OPTION(BUILD_ANDROID_PACKAGE "Build platform-specific package for Google Play" OFF IF ANDROID )
|
||||
|
||||
# 3rd party libs
|
||||
OCV_OPTION(BUILD_ZLIB "Build zlib from source" WIN32 OR APPLE OR CARMA )
|
||||
OCV_OPTION(BUILD_TIFF "Build libtiff from source" WIN32 OR ANDROID OR APPLE OR CARMA )
|
||||
OCV_OPTION(BUILD_JASPER "Build libjasper from source" WIN32 OR ANDROID OR APPLE OR CARMA )
|
||||
OCV_OPTION(BUILD_JPEG "Build libjpeg from source" WIN32 OR ANDROID OR APPLE OR CARMA )
|
||||
OCV_OPTION(BUILD_PNG "Build libpng from source" WIN32 OR ANDROID OR APPLE OR CARMA )
|
||||
OCV_OPTION(BUILD_OPENEXR "Build openexr from source" WIN32 OR ANDROID OR APPLE OR CARMA )
|
||||
|
||||
OCV_OPTION(BUILD_ZLIB "Build zlib from source" WIN32 OR APPLE OR CARMA )
|
||||
OCV_OPTION(BUILD_TIFF "Build libtiff from source" WIN32 OR ANDROID OR APPLE OR CARMA )
|
||||
OCV_OPTION(BUILD_JASPER "Build libjasper from source" WIN32 OR ANDROID OR APPLE OR CARMA )
|
||||
OCV_OPTION(BUILD_JPEG "Build libjpeg from source" WIN32 OR ANDROID OR APPLE OR CARMA )
|
||||
OCV_OPTION(BUILD_PNG "Build libpng from source" WIN32 OR ANDROID OR APPLE OR CARMA )
|
||||
OCV_OPTION(BUILD_OPENEXR "Build openexr from source" WIN32 OR ANDROID OR APPLE OR CARMA )
|
||||
OCV_OPTION(BUILD_TBB "Download and build TBB from source" ANDROID IF CMAKE_COMPILER_IS_GNUCXX )
|
||||
|
||||
# OpenCV installation options
|
||||
# ===================================================
|
||||
|
@ -1,4 +1,4 @@
|
||||
if(ANDROID AND NOT MIPS)
|
||||
if(BUILD_TBB)
|
||||
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/tbb")
|
||||
include_directories(SYSTEM ${TBB_INCLUDE_DIRS})
|
||||
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} tbb)
|
||||
|
100
platforms/linux/arm-gnueabi.toolchain.cmake
Normal file
100
platforms/linux/arm-gnueabi.toolchain.cmake
Normal file
@ -0,0 +1,100 @@
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_VERSION 1)
|
||||
set(CMAKE_SYSTEM_PROCESSOR arm)
|
||||
|
||||
if (CARMA)
|
||||
set(GCC_COMPILER_VERSION "4.5" CACHE STRING "GCC Compiler version")
|
||||
else()
|
||||
set(GCC_COMPILER_VERSION "4.6" CACHE STRING "GCC Compiler version")
|
||||
endif()
|
||||
|
||||
set(FLOAT_ABI_SUFFIX "")
|
||||
|
||||
if (NOT SOFTFP)
|
||||
set(FLOAT_ABI_SUFFIX "hf")
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_COMPILER arm-linux-gnueabi${FLOAT_ABI_SUFFIX}-gcc-${GCC_COMPILER_VERSION})
|
||||
set(CMAKE_CXX_COMPILER arm-linux-gnueabi${FLOAT_ABI_SUFFIX}-g++-${GCC_COMPILER_VERSION})
|
||||
set(ARM_LINUX_SYSROOT /usr/arm-linux-gnueabi${FLOAT_ABI_SUFFIX} CACHE PATH "ARM cross compilation system root")
|
||||
|
||||
set(CMAKE_CXX_FLAGS "" CACHE STRING "c++ flags")
|
||||
set(CMAKE_C_FLAGS "" CACHE STRING "c flags")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "" CACHE STRING "shared linker flags")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS "" CACHE STRING "module linker flags")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-Wl,-z,nocopyreloc" CACHE STRING "executable linker flags")
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mthumb -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mthumb -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi")
|
||||
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now ${CMAKE_SHARED_LINKER_FLAGS}")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now ${CMAKE_MODULE_LINKER_FLAGS}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now ${CMAKE_EXE_LINKER_FLAGS}")
|
||||
|
||||
if(USE_NEON)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=neon")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=neon")
|
||||
elseif(USE_VFPV3)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=vfpv3")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=vfpv3")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=vfpv3-d16")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpu=vfpv3-d16")
|
||||
endif()
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${ARM_LINUX_SYSROOT})
|
||||
|
||||
if(EXISTS ${CUDA_TOOLKIT_ROOT_DIR})
|
||||
set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${CUDA_TOOLKIT_ROOT_DIR})
|
||||
endif()
|
||||
|
||||
set( CMAKE_SKIP_RPATH TRUE CACHE BOOL "If set, runtime paths are not added when using shared libraries." )
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
|
||||
|
||||
if (CARMA)
|
||||
add_definitions(-DCARMA)
|
||||
endif()
|
||||
|
||||
# macro to find programs on the host OS
|
||||
macro( find_host_program )
|
||||
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
|
||||
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER )
|
||||
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER )
|
||||
if( CMAKE_HOST_WIN32 )
|
||||
SET( WIN32 1 )
|
||||
SET( UNIX )
|
||||
elseif( CMAKE_HOST_APPLE )
|
||||
SET( APPLE 1 )
|
||||
SET( UNIX )
|
||||
endif()
|
||||
find_program( ${ARGN} )
|
||||
SET( WIN32 )
|
||||
SET( APPLE )
|
||||
SET( UNIX 1 )
|
||||
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
|
||||
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
|
||||
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
|
||||
endmacro()
|
||||
|
||||
# macro to find packages on the host OS
|
||||
macro( find_host_package )
|
||||
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
|
||||
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER )
|
||||
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER )
|
||||
if( CMAKE_HOST_WIN32 )
|
||||
SET( WIN32 1 )
|
||||
SET( UNIX )
|
||||
elseif( CMAKE_HOST_APPLE )
|
||||
SET( APPLE 1 )
|
||||
SET( UNIX )
|
||||
endif()
|
||||
find_package( ${ARGN} )
|
||||
SET( WIN32 )
|
||||
SET( APPLE )
|
||||
SET( UNIX 1 )
|
||||
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
|
||||
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
|
||||
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
|
||||
endmacro()
|
8
platforms/linux/scripts/cmake_arm_gnueabi_hardfp.sh
Executable file
8
platforms/linux/scripts/cmake_arm_gnueabi_hardfp.sh
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
cd `dirname $0`/..
|
||||
|
||||
mkdir -p build_hardfp
|
||||
cd build_hardfp
|
||||
|
||||
cmake -DCMAKE_TOOLCHAIN_FILE=../arm-gnueabi.toolchain.cmake $@ ../../..
|
||||
|
8
platforms/linux/scripts/cmake_arm_gnueabi_softfp.sh
Executable file
8
platforms/linux/scripts/cmake_arm_gnueabi_softfp.sh
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
cd `dirname $0`/..
|
||||
|
||||
mkdir -p build_softfp
|
||||
cd build_softfp
|
||||
|
||||
cmake -DSOFTFP=ON -DCMAKE_TOOLCHAIN_FILE=../arm-gnueabi.toolchain.cmake $@ ../../..
|
||||
|
8
platforms/linux/scripts/cmake_carma.sh
Executable file
8
platforms/linux/scripts/cmake_carma.sh
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
mkdir -p build_carma
|
||||
cd build_carma
|
||||
|
||||
cmake -DSOFTFP=ON -DCARMA=ON -DWITH_TBB=ON -DBUILD_TBB=ON -DUSE_NEON=ON -DCUDA_TOOLKIT_ROOT_DIR=/usr/arm-linux-gnueabi/cuda/ \
|
||||
-DCUDA_ARCH_BIN="2.1(2.0)" -DCUDA_ARCH_PTX="" -DCMAKE_SKIP_RPATH=ON -DWITH_CUDA=ON -DWITH_CUBLAS=ON \
|
||||
-DCMAKE_TOOLCHAIN_FILE=../arm-gnueabi.toolchain.cmake $@ ../../..
|
1
platforms/readme.txt
Normal file
1
platforms/readme.txt
Normal file
@ -0,0 +1 @@
|
||||
This folder contains toolchains and additional files that are needed for cross compitation.
|
Loading…
Reference in New Issue
Block a user