Mercurial > ~darius > hgwebdir.cgi > modulator
view local.cmake @ 0:a55e39064a71
First commit of code that compiles.
Does nothing like it should but has cmake goo to wrap dat files
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Mon, 29 Mar 2021 13:48:34 +1030 |
parents | |
children | b9ec45077bff |
line wrap: on
line source
function(bin2elf TARGET BINFILE) cmake_parse_arguments(bin2elf "" "OUTPUT_DIR" "" ${ARGN}) set(FILENAME "${CMAKE_SOURCE_DIR}/${BINFILE}") set(ELFNAME "${CMAKE_CURRENT_BINARY_DIR}/${BINFILE}.o") #message("FILENAME ${FILENAME} ELFNAME ${ELFNAME}") # Not sure why but we can't depend directly, have to create this intermediary # Copied idea from pico_generate_pio_header get_filename_component(BIN_GEN_TARGET ${BINFILE} NAME_WE) set(BIN_GEN_TARGET "${TARGET}_${BIN_GEN_TARGET}") add_custom_target(${BIN_GEN_TARGET} DEPENDS ${ELFNAME}) # Create symbol name for bin file string(MAKE_C_IDENTIFIER ${BINFILE} BIN_SYMNAME) #message("BINFILE ${BINFILE} BIN_SYMNAME ${BIN_SYMNAME}") # Get directory name of source file # ld will name the symbol based on the full path so we have to mangle it get_filename_component(BIN_SRC_DIR ${FILENAME} DIRECTORY) string(REPLACE "/" "_" SRC_DIRNAME_MANGLED ${BIN_SRC_DIR}) #message("SRC_DIRNAME_MANGLED ${SRC_DIRNAME_MANGLED}") add_custom_command(OUTPUT ${ELFNAME} COMMAND arm-none-eabi-ld -r -b binary -o ${ELFNAME} --defsym=${BIN_SYMNAME}_start=_binary_${SRC_DIRNAME_MANGLED}_${BIN_SYMNAME}_start --defsym=${BIN_SYMNAME}_size=_binary_${SRC_DIRNAME_MANGLED}_${BIN_SYMNAME}_size ${FILENAME} DEPENDS ${FILENAME}) add_dependencies(${TARGET} ${BIN_GEN_TARGET}) # Add object file to list of things to be linked target_link_libraries(${TARGET} ${CMAKE_CURRENT_BINARY_DIR}/${ELFNAME}) endfunction()