Skip to content

Instantly share code, notes, and snippets.

@tisyang
Created January 31, 2019 00:58
Show Gist options
  • Save tisyang/c74e7e9f2986b7dae1c22e8009a2eb5f to your computer and use it in GitHub Desktop.
Save tisyang/c74e7e9f2986b7dae1c22e8009a2eb5f to your computer and use it in GitHub Desktop.
cmake cross compile toolchain files
# this one is important
SET(CMAKE_SYSTEM_NAME Linux)
SET(SYSTEM_NAME aarch64-linux-gnu)
#this one not so much
SET(CMAKE_SYSTEM_VERSION 1)
# specify the cross compiler
SET(CMAKE_C_COMPILER ${SYSTEM_NAME}-gcc)
SET(CMAKE_CXX_COMPILER ${SYSTEM_NAME}-g++)
# where is the target environment
SET(CMAKE_FIND_ROOT_PATH /usr/${SYSTEM_NAME})
# 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)
# this one is important
SET(CMAKE_SYSTEM_NAME Linux)
SET(SYSTEM_NAME arm-linux-gnueabi)
#this one not so much
SET(CMAKE_SYSTEM_VERSION 1)
# specify the cross compiler
SET(CMAKE_C_COMPILER ${SYSTEM_NAME}-gcc)
SET(CMAKE_CXX_COMPILER ${SYSTEM_NAME}-g++)
# where is the target environment
SET(CMAKE_FIND_ROOT_PATH /usr/${SYSTEM_NAME})
# 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)
# this one is important
SET(CMAKE_SYSTEM_NAME Linux)
SET(SYSTEM_NAME arm-linux-gnueabihf)
#this one not so much
SET(CMAKE_SYSTEM_VERSION 1)
# specify the cross compiler
SET(CMAKE_C_COMPILER ${SYSTEM_NAME}-gcc)
SET(CMAKE_CXX_COMPILER ${SYSTEM_NAME}-g++)
# where is the target environment
SET(CMAKE_FIND_ROOT_PATH /usr/${SYSTEM_NAME})
# 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment