From cfea1de2e8ee59800323aea3af63059a4a9f2700 Mon Sep 17 00:00:00 2001 From: Jacob Alexander Date: Fri, 18 Apr 2014 21:58:14 -0700 Subject: [PATCH] Let CMake do more autoconfiguration. --- CMakeLists.txt | 11 +++++++---- arm.cmake | 12 +++--------- avr.cmake | 8 +------- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dbe8b2a..7d20d85 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,9 @@ message( "${COMPILER_FAMILY}" ) #| Load the compiler family specific configurations include( ${COMPILER_FAMILY}.cmake ) +#| Binutils not set by CMake +set( CMAKE_SIZE "${_CMAKE_TOOLCHAIN_PREFIX}size" ) + ### @@ -114,7 +117,7 @@ set_target_properties( ${TARGET_ELF} PROPERTIES #| Convert the .ELF into a .HEX to load onto the Teensy set( TARGET_HEX ${TARGET}.hex ) add_custom_command( TARGET ${TARGET_ELF} POST_BUILD - COMMAND ${OBJCOPY} ${HEX_FLAGS} ${TARGET_ELF} ${TARGET_HEX} + COMMAND ${CMAKE_OBJCOPY} ${HEX_FLAGS} ${TARGET_ELF} ${TARGET_HEX} COMMENT "Creating load file for Flash: ${TARGET_HEX}" ) @@ -122,7 +125,7 @@ add_custom_command( TARGET ${TARGET_ELF} POST_BUILD #| Generate the Extended .LSS set( TARGET_LSS ${TARGET}.lss ) add_custom_command( TARGET ${TARGET_ELF} POST_BUILD - COMMAND ${OBJDUMP} ${LSS_FLAGS} ${TARGET_ELF} > ${TARGET_LSS} + COMMAND ${CMAKE_OBJDUMP} ${LSS_FLAGS} ${TARGET_ELF} > ${TARGET_LSS} COMMENT "Creating Extended Listing: ${TARGET_LSS}" ) @@ -130,7 +133,7 @@ add_custom_command( TARGET ${TARGET_ELF} POST_BUILD #| Generate the Symbol Table .SYM set( TARGET_SYM ${TARGET}.sym ) add_custom_command( TARGET ${TARGET_ELF} POST_BUILD - COMMAND ${NM} -n ${TARGET_ELF} > ${TARGET_SYM} + COMMAND ${CMAKE_NM} -n ${TARGET_ELF} > ${TARGET_SYM} COMMENT "Creating Symbol Table: ${TARGET_SYM}" ) @@ -143,7 +146,7 @@ add_custom_command( TARGET ${TARGET_ELF} POST_BUILD #| After Changes Size Information #| TODO Do lookup on Flash and RAM sizes and do % used add_custom_target( SizeAfter ALL - COMMAND ${SIZE} --target=${FORMAT} ${TARGET_HEX} ${TARGET_ELF} + COMMAND ${CMAKE_SIZE} --target=${FORMAT} ${TARGET_HEX} ${TARGET_ELF} DEPENDS ${TARGET_ELF} COMMENT "Size after generation\n\tFlash Usage: data (hex)\n\t RAM Usage: data (elf)" ) diff --git a/arm.cmake b/arm.cmake index 3a9b8b5..d11b89f 100644 --- a/arm.cmake +++ b/arm.cmake @@ -13,15 +13,9 @@ #| Set the Compilers (must be set first) include( CMakeForceCompiler ) -cmake_force_c_compiler ( arm-none-eabi-gcc AVRCCompiler ) -cmake_force_cxx_compiler( arm-none-eabi-g++ AVRCxxCompiler ) - - -#| Compiler Binaries -set( OBJCOPY "arm-none-eabi-objcopy" ) -set( OBJDUMP "arm-none-eabi-objdump" ) -set( NM "arm-none-eabi-nm" ) -set( SIZE "arm-none-eabi-size" ) +cmake_force_c_compiler ( arm-none-eabi-gcc ARMCCompiler ) +cmake_force_cxx_compiler( arm-none-eabi-g++ ARMCxxCompiler ) +set( _CMAKE_TOOLCHAIN_PREFIX arm-none-eabi- ) diff --git a/avr.cmake b/avr.cmake index 3c82292..0af5216 100644 --- a/avr.cmake +++ b/avr.cmake @@ -15,13 +15,7 @@ include( CMakeForceCompiler ) cmake_force_c_compiler ( avr-gcc AVRCCompiler ) cmake_force_cxx_compiler( avr-g++ AVRCxxCompiler ) - - -#| Compiler Binaries -set( OBJCOPY "avr-objcopy" ) -set( OBJDUMP "avr-objdump" ) -set( NM "avr-nm" ) -set( SIZE "avr-size" ) +set( _CMAKE_TOOLCHAIN_PREFIX avr- )