2015-09-07 21:37:45 -03:00
|
|
|
# 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-none-eabi-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-none-eabi-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
|
2015-09-13 15:31:58 -03:00
|
|
|
foreach(tool objcopy nm ld gdb)
|
2015-09-07 21:37:45 -03:00
|
|
|
string(TOUPPER ${tool} TOOL)
|
|
|
|
find_program(${TOOL} arm-none-eabi-${tool})
|
|
|
|
if(NOT ${TOOL})
|
2015-09-08 05:17:54 -03:00
|
|
|
message(FATAL_ERROR "could not find ${tool}")
|
2015-09-07 21:37:45 -03:00
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
# os tools
|
2015-09-08 05:17:54 -03:00
|
|
|
foreach(tool echo patch grep rm mkdir nm genromfs awk cp touch make unzip)
|
2015-09-07 21:37:45 -03:00
|
|
|
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)
|