这里我想在Linux x64机器上交叉编译cmake的一些cuda代码:
> # CMakeLists.txt to build hellocuda.cu
>cmake_minimum_required(VERSION 2.8)
>find_package(CUDA QUIET REQUIRED)
>
> # this one is important
>SET(CMAKE_SYSTEM_NAME Linux)
>set( CMAKE_SYSTEM_PROCESSOR arm )
>
> # specify the cross compiler
>SET (CMAKE_C_COMPILER /usr/bin/arm-linux-gnueabihf-gcc )
>SET (CMAKE_CXX_COMPILER /usr/bin/arm-linux-gnueabihf-g++ )
>
> # where is the target environment
>SET(CMAKE_FIND_ROOT_PATH /usr/arm-linux-gnueabihf/bin )
>
> # 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)
>
> #make build verbose
>SET (CUDA_VERBOSE_BUILD ON CACHE BOOL "nvcc verbose" FORCE)
>
> #make makefile verbose
>SET ( CMAKE_VERBOSE_MAKEFILE TRUE CACHE BOOL "verbose makefile" FORECE)
>
> #target device is 32 bit
>SET (CUDA_64_BIT_DEVICE_CODE OFF CACHE BOOL "device code" FORCE)
>
> #use armhf c++ compiler
>SET (CUDA_HOST_COMPILER "/usr/bin/arm-linux-gnueabihf-g++" CACHE STRING "host compiler" FORCE)
>
> # Pass options to NVCC
> #set( CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}; -gencode arch=compute_20,code=sm_20 )
>
> # Specify binary name and source file to build it from
> cuda_add_executable( hellocuda src/hellocuda.cu )
但我不明白如何告诉nvcc为ARM编译