Skip to content

Instantly share code, notes, and snippets.

@vpetrigo
Created December 5, 2016 21:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vpetrigo/29e3bfbe7d4aa133e4f661c8420af172 to your computer and use it in GitHub Desktop.
Save vpetrigo/29e3bfbe7d4aa133e4f661c8420af172 to your computer and use it in GitHub Desktop.
CMake template for using Clang + ARM toolchain
cmake_minimum_required(VERSION 3.2)
set(CMAKE_CROSSCOMPILING TRUE)
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(gcc_toolchain "$ENV{USERPROFILE}\\Documents\\Projects\\toolchains\\gcc-mingw32-arm-linux-gnueabihf")
set(triple arm-linux-gnueabihf)
set(cpu_type cortex-a7)
set(fpu_type neon-vfpv4)
set(float_abi_type hard)
set(CMAKE_C_COMPILER clang)
set(CMAKE_C_COMPILER_TARGET ${triple})
set(CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN ${gcc_toolchain})
set(CMAKE_SYSROOT ${gcc_toolchain}\\arm-linux-gnueabihf\\libc)
set(CMAKE_C_FLAGS_INIT "${CMAKE_C_FLAGS_INIT} -B${gcc_toolchain}\\bin -mcpu=${cpu_type} -mfpu=${fpu_type} -mfloat-abi=${float_abi_type}")
project(arm_test C)
set(arm_test_SRC main.c)
add_executable(arm_test ${arm_test_SRC})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment