Skip to content

Commit

Permalink
Improvements to cross compile system.
Browse files Browse the repository at this point in the history
  • Loading branch information
naibaf7 committed Jun 2, 2018
1 parent 97f4f74 commit dcda290
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 11 deletions.
11 changes: 7 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,24 +113,27 @@ endif()

# ---[ Cross compile for ARM (Asus Tinkerboard, Rasperry Pi)
if(USE_ARM_CROSS_COMPILE)
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_CROSSCOMPILING TRUE)
set(CMAKE_PREFIX_PATH "${CMAKE_FIND_ROOT_PATH}")
set(CMAKE_SYSROOT "${CMAKE_FIND_ROOT_PATH}")
set(CMAKE_SYSROOT_COMPILE "${CMAKE_FIND_ROOT_PATH}")
set(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES "${CMAKE_FIND_ROOT_PATH}/usr/include")
set(CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES "${CMAKE_FIND_ROOT_PATH}/usr/include")
set(CMAKE_CUDA_IMPLICIT_INCLUDE_DIRECTORIES "${CMAKE_FIND_ROOT_PATH}/usr/include")
set(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES "${CMAKE_FIND_ROOT_PATH}/usr/include;${CMAKE_FIND_ROOT_PATH}/usr/include/arm-linux-gnueabihf")
set(CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES "${CMAKE_FIND_ROOT_PATH}/usr/include;${CMAKE_FIND_ROOT_PATH}/usr/include/arm-linux-gnueabihf")
set(CMAKE_CUDA_IMPLICIT_INCLUDE_DIRECTORIES "${CMAKE_FIND_ROOT_PATH}/usr/include;${CMAKE_FIND_ROOT_PATH}/usr/include/arm-linux-gnueabihf")
include_directories(PUBLIC "${CMAKE_FIND_ROOT_PATH}/usr/include;${CMAKE_FIND_ROOT_PATH}/usr/include/arm-linux-gnueabihf")
set(CMAKE_INSTALL_OLDINCLUDEDIR "${CMAKE_FIND_ROOT_PATH}/usr/include" CACHE STRING "Header files" FORCE)
set(USE_HDF5 OFF CACHE BOOL "Build with hdf5" FORCE)
set(BOOST_INCLUDEDIR "${CMAKE_FIND_ROOT_PATH}/usr/include" CACHE STRING "Boost inculde path")
set(BOOST_LIBRARYDIR "${CMAKE_FIND_ROOT_PATH}/usr/lib/arm-linux-gnueabihf" CACHE STRING "Caffe logical version")
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
unset(COMPILER_SUPPORTS_ARMV7ANEON CACHE)
CHECK_CXX_COMPILER_FLAG("-march=armv7-a" COMPILER_SUPPORTS_ARMV7ANEON)
if(COMPILER_SUPPORTS_ARMV7ANEON)
message("Using armv7a-neon target")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv7-a")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lm")
endif()

if(USE_ISAAC)
Expand Down
4 changes: 2 additions & 2 deletions cmake/Modules/FindGFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ set(GFLAGS_ROOT_DIR "" CACHE PATH "Folder contains Gflags")

# We are testing only a couple of files in the include directories
find_path(GFLAGS_INCLUDE_DIR gflags/gflags.h
PATHS ${GFLAGS_ROOT_DIR} /usr/include)
PATHS ${GFLAGS_ROOT_DIR} "/usr/include")

if(MSVC)
# rely on gflags-config.cmake
Expand All @@ -24,7 +24,7 @@ if(MSVC)
set(GFLAGS_LIBRARY ${gflags_LIBRARIES})
set(GFLAGS_INCLUDE_DIR ${gflags_INCLUDE_DIRS})
else()
find_library(GFLAGS_LIBRARY gflags)
find_library(GFLAGS_LIBRARY gflags PATHS "/usr/lib" "/usr/lib64" "/usr/lib/arm-linux-gnueabihf")
endif()

find_package_handle_standard_args(GFlags DEFAULT_MSG GFLAGS_INCLUDE_DIR GFLAGS_LIBRARY)
Expand Down
2 changes: 1 addition & 1 deletion cmake/Modules/FindGlog.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if(MSVC)
set(GLOG_INCLUDE_DIR ${glog_INCLUDE_DIRS})
else()
find_library(GLOG_LIBRARY glog
PATHS ${GLOG_ROOT_DIR}
PATHS ${GLOG_ROOT_DIR} "/usr/lib" "/usr/lib64" "/usr/lib/arm-linux-gnueabihf"
PATH_SUFFIXES lib lib64)
endif()

Expand Down
2 changes: 1 addition & 1 deletion cmake/Modules/FindLMDB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if(MSVC)
find_package(LMDB NO_MODULE)
else()
find_path(LMDB_INCLUDE_DIR NAMES lmdb.h PATHS "$ENV{LMDB_DIR}/include" "/usr/include")
find_library(LMDB_LIBRARIES NAMES lmdb PATHS "$ENV{LMDB_DIR}/lib" "/usr/lib" "/usr/lib64")
find_library(LMDB_LIBRARIES NAMES lmdb PATHS "$ENV{LMDB_DIR}/lib" "/usr/lib" "/usr/lib64" "/usr/lib/arm-linux-gnueabihf")
endif()

include(FindPackageHandleStandardArgs)
Expand Down
2 changes: 1 addition & 1 deletion cmake/Modules/FindLevelDB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ else()

# Look for the library.
find_library(LevelDB_LIBRARY NAMES leveldb
PATHS "$ENV{LEVELDB_ROOT}/lib" "/usr/lib" "/usr/lib64"
PATHS "$ENV{LEVELDB_ROOT}/lib" "/usr/lib" "/usr/lib64" "/usr/lib/arm-linux-gnueabihf"
DOC "Path to leveldb library." )
endif()

Expand Down
2 changes: 1 addition & 1 deletion cmake/Modules/FindOpenCL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ ELSE (APPLE)

# Unix style platforms
FIND_LIBRARY(OPENCL_LIBRARIES OpenCL${OCL_LIB_SUFFIX}
PATHS ENV LD_LIBRARY_PATH ENV OpenCL_LIBPATH
PATHS ENV LD_LIBRARY_PATH ENV OpenCL_LIBPATH "/lib" "/usr/lib" "/usr/lib64" "/usr/lib/arm-linux-gnueabihf"
)

GET_FILENAME_COMPONENT(OPENCL_LIB_DIR ${OPENCL_LIBRARIES} PATH)
Expand Down
2 changes: 1 addition & 1 deletion cmake/Modules/FindSnappy.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ else()
PATHS "${SNAPPY_ROOT_DIR}" "${SNAPPY_ROOT_DIR}/include" "/usr/include")

find_library(Snappy_LIBRARIES NAMES snappy
PATHS "${SNAPPY_ROOT_DIR}" "${SNAPPY_ROOT_DIR}/lib" "/usr/lib" "/usr/lib64")
PATHS "${SNAPPY_ROOT_DIR}" "${SNAPPY_ROOT_DIR}/lib" "/usr/lib" "/usr/lib64" "/usr/lib/arm-linux-gnueabihf")
endif()

include(FindPackageHandleStandardArgs)
Expand Down

0 comments on commit dcda290

Please sign in to comment.