From 0047b38c5491dbf4d397b8de9991d322ba3f55ec Mon Sep 17 00:00:00 2001 From: Mark Charlebois Date: Thu, 10 Sep 2015 19:52:23 -0700 Subject: [PATCH] cmake: added Toolchain-arm-linux-gnueabihf Signed-off-by: Mark Charlebois --- .../configs/config_posix_eagle_default.cmake | 2 + cmake/configs/config_posix_eagle_hil.cmake | 2 + cmake/configs/config_posix_eagle_muorb.cmake | 2 + .../configs/config_posix_eagle_release.cmake | 2 + .../Toolchain-arm-linux-gnueabihf.cmake | 67 +++++++++++++++++++ 5 files changed, 75 insertions(+) create mode 100644 cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake diff --git a/cmake/configs/config_posix_eagle_default.cmake b/cmake/configs/config_posix_eagle_default.cmake index ddbf058bc7..228b4e50ae 100644 --- a/cmake/configs/config_posix_eagle_default.cmake +++ b/cmake/configs/config_posix_eagle_default.cmake @@ -1,5 +1,7 @@ include(posix/px4_impl_posix-arm) +set(USE_TOOLCHAIN Toolchain-arm-linux-gnueabihf) + function(px4_get_config) px4_parse_function_args( diff --git a/cmake/configs/config_posix_eagle_hil.cmake b/cmake/configs/config_posix_eagle_hil.cmake index be779e143f..af3785f5c7 100644 --- a/cmake/configs/config_posix_eagle_hil.cmake +++ b/cmake/configs/config_posix_eagle_hil.cmake @@ -1,5 +1,7 @@ include(posix/px4_impl_posix-arm) +set(USE_TOOLCHAIN Toolchain-arm-linux-gnueabihf) + function(px4_get_config) px4_parse_function_args( diff --git a/cmake/configs/config_posix_eagle_muorb.cmake b/cmake/configs/config_posix_eagle_muorb.cmake index c08e43861d..450d7b1e4e 100644 --- a/cmake/configs/config_posix_eagle_muorb.cmake +++ b/cmake/configs/config_posix_eagle_muorb.cmake @@ -1,5 +1,7 @@ include(posix/px4_impl_posix-arm) +set(USE_TOOLCHAIN Toolchain-arm-linux-gnueabihf) + function(px4_get_config) px4_parse_function_args( diff --git a/cmake/configs/config_posix_eagle_release.cmake b/cmake/configs/config_posix_eagle_release.cmake index 90d2e40b86..cc220cb306 100644 --- a/cmake/configs/config_posix_eagle_release.cmake +++ b/cmake/configs/config_posix_eagle_release.cmake @@ -1,5 +1,7 @@ include(posix/px4_impl_posix-arm) +set(USE_TOOLCHAIN Toolchain-arm-linux-gnueabihf) + function(px4_get_config) px4_parse_function_args( diff --git a/cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake b/cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake new file mode 100644 index 0000000000..2db5cf82b9 --- /dev/null +++ b/cmake/toolchains/Toolchain-arm-linux-gnueabihf.cmake @@ -0,0 +1,67 @@ +# defines: +# +# NM +# OBJCOPY +# LD +# CXX_COMPILER +# C_COMPILER +# CMAKE_SYSTEM_NAME +# CMAKE_SYSTEM_VERSION +# GENROMFS +# LINKER_FLAGS +# CMAKE_EXE_LINKER_FLAGS +# CMAKE_FIND_ROOT_PATH +# CMAKE_FIND_ROOT_PATH_MODE_PROGRAM +# CMAKE_FIND_ROOT_PATH_MODE_LIBRARY +# CMAKE_FIND_ROOT_PATH_MODE_INCLUDE + +include(CMakeForceCompiler) + +# this one is important +set(CMAKE_SYSTEM_NAME Generic) + +#this one not so much +set(CMAKE_SYSTEM_VERSION 1) + +# specify the cross compiler +find_program(C_COMPILER arm-linux-gnueabihf-gcc) +if(NOT C_COMPILER) + message(FATAL_ERROR "could not find arm-none-eabi-gcc compiler") +endif() +cmake_force_c_compiler(${C_COMPILER} GNU) + +find_program(CXX_COMPILER arm-linux-gnueabihf-g++) +if(NOT CXX_COMPILER) + message(FATAL_ERROR "could not find arm-none-eabi-g++ compiler") +endif() +cmake_force_cxx_compiler(${CXX_COMPILER} GNU) + +# compiler tools +foreach(tool objcopy nm ld) + string(TOUPPER ${tool} TOOL) + find_program(${TOOL} arm-linux-gnueabihf-${tool}) + if(NOT ${TOOL}) + message(FATAL_ERROR "could not find ${tool}") + endif() +endforeach() + +# os tools +foreach(tool echo patch grep rm mkdir nm genromfs awk cp touch make unzip) + string(TOUPPER ${tool} TOOL) + find_program(${TOOL} ${tool}) + if(NOT ${TOOL}) + message(FATAL_ERROR "could not find ${TOOL}") + endif() +endforeach() + +set(LINKER_FLAGS "-Wl,-gc-sections") +set(CMAKE_EXE_LINKER_FLAGS ${LINKER_FLAGS}) + +# where is the target environment +set(CMAKE_FIND_ROOT_PATH get_file_component(${C_COMPILER} PATH)) + +# 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)