1set(CMAKE_SYSTEM_NAME Linux)
2set(CMAKE_SYSTEM_VERSION 1)
3set(CMAKE_SYSTEM_PROCESSOR arm)
4
5set(GCC_COMPILER_VERSION "4.6" CACHE STRING "GCC Compiler version")
6
7set(FLOAT_ABI_SUFFIX "")
8if (NOT SOFTFP)
9  set(FLOAT_ABI_SUFFIX "hf")
10endif()
11
12find_program(CMAKE_C_COMPILER NAMES arm-linux-gnueabi${FLOAT_ABI_SUFFIX}-gcc-${GCC_COMPILER_VERSION})
13find_program(CMAKE_CXX_COMPILER NAMES arm-linux-gnueabi${FLOAT_ABI_SUFFIX}-g++-${GCC_COMPILER_VERSION})
14set(ARM_LINUX_SYSROOT /usr/arm-linux-gnueabi${FLOAT_ABI_SUFFIX} CACHE PATH "ARM cross compilation system root")
15
16set(CMAKE_CXX_FLAGS           ""                    CACHE STRING "c++ flags")
17set(CMAKE_C_FLAGS             ""                    CACHE STRING "c flags")
18set(CMAKE_SHARED_LINKER_FLAGS ""                    CACHE STRING "shared linker flags")
19set(CMAKE_MODULE_LINKER_FLAGS ""                    CACHE STRING "module linker flags")
20set(CMAKE_EXE_LINKER_FLAGS    "-Wl,-z,nocopyreloc"  CACHE STRING "executable linker flags")
21
22set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mthumb -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi")
23set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -mthumb -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi")
24
25set(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}")
26set(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}")
27set(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}")
28
29if(USE_NEON)
30  message(WARNING "You use obsolete variable USE_NEON to enable NEON instruction set. Use -DENABLE_NEON=ON instead." )
31  set(ENABLE_NEON TRUE)
32elseif(USE_VFPV3)
33  message(WARNING "You use obsolete variable USE_VFPV3 to enable VFPV3 instruction set. Use -DENABLE_VFPV3=ON instead." )
34  set(ENABLE_VFPV3 TRUE)
35endif()
36
37set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${ARM_LINUX_SYSROOT})
38
39if(EXISTS ${CUDA_TOOLKIT_ROOT_DIR})
40    set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${CUDA_TOOLKIT_ROOT_DIR})
41endif()
42
43set( CMAKE_SKIP_RPATH TRUE CACHE BOOL "If set, runtime paths are not added when using shared libraries." )
44set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
45set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
46set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
47
48# macro to find programs on the host OS
49macro( find_host_program )
50 set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
51 set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER )
52 set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER )
53 if( CMAKE_HOST_WIN32 )
54  SET( WIN32 1 )
55  SET( UNIX )
56 elseif( CMAKE_HOST_APPLE )
57  SET( APPLE 1 )
58  SET( UNIX )
59 endif()
60 find_program( ${ARGN} )
61 SET( WIN32 )
62 SET( APPLE )
63 SET( UNIX 1 )
64 set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
65 set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
66 set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
67endmacro()
68
69# macro to find packages on the host OS
70macro( find_host_package )
71 set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
72 set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER )
73 set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER )
74 if( CMAKE_HOST_WIN32 )
75  SET( WIN32 1 )
76  SET( UNIX )
77 elseif( CMAKE_HOST_APPLE )
78  SET( APPLE 1 )
79  SET( UNIX )
80 endif()
81 find_package( ${ARGN} )
82 SET( WIN32 )
83 SET( APPLE )
84 SET( UNIX 1 )
85 set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
86 set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
87 set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
88endmacro()
89