Adding compiler change detection.

- Tried to add auto cmake reset...so far unsuccessful
- Ported MBC-55X (was used to test compilers)
- Disabled in-source builds, to prevent CMake from shooting itself in the foot.
This commit is contained in:
Jacob Alexander 2014-04-19 01:51:25 -07:00
parent c424923698
commit 5df7b55391
5 changed files with 335 additions and 12 deletions

View file

@ -12,6 +12,10 @@ set( CMAKE_LEGACY_CYGWIN_WIN32 0 )
set( CMAKE_USE_RELATIVE_PATHS 1 )
#| Prevent In-Source Builds
set( CMAKE_DISABLE_SOURCE_CHANGES ON )
set( CMAKE_DISABLE_IN_SOURCE_BUILD ON )
###
# Compiler Lookup
@ -34,6 +38,17 @@ endif ()
message( STATUS "Compiler Family:" )
message( "${COMPILER_FAMILY}" )
#| Compiler Selection Record
#| This is used to check if the chip target has changed (a complete cmake reset is needed)
if ( EXISTS compiler )
file( READ ${CMAKE_BINARY_DIR}/compiler COMPILER_RECORD )
# Detect case if a full cmake reset is required
if ( NOT COMPILER_FAMILY STREQUAL COMPILER_RECORD )
message( FATAL_ERROR "Changing compilers requires a cmake reset\ne.g. rm -rf *; cmake .." )
endif()
endif ()
#| Load the compiler family specific configurations
include( Lib/CMake/${COMPILER_FAMILY}.cmake )

View file

@ -259,7 +259,7 @@ set_target_properties( ${TARGET_ELF} PROPERTIES
set( TARGET_HEX ${TARGET}.hex )
add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
COMMAND ${CMAKE_OBJCOPY} ${HEX_FLAGS} ${TARGET_ELF} ${TARGET_HEX}
COMMENT "Creating load file for Flash: ${TARGET_HEX}"
COMMENT "Creating iHex file to load: ${TARGET_HEX}"
)
@ -279,6 +279,12 @@ add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
)
#| Compiler Selection Record
add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
COMMAND ${CMAKE_SOURCE_DIR}/Lib/CMake/writer compiler ${COMPILER_FAMILY}
)
###
# Size Information

10
Lib/CMake/writer Executable file
View file

@ -0,0 +1,10 @@
#!/bin/bash
#| Jacob Alexander 2014
#| Arg List
#| 1 - File to write to (e.g. final_chip)
#| 2 - Contents writing to file (e.g. at90usb1286)
printf "$2" > "$1"
exit $?