Mercurial > ~darius > hgwebdir.cgi > modulator
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a55e39064a71 |
---|---|
1 function(bin2elf TARGET BINFILE) | |
2 cmake_parse_arguments(bin2elf "" "OUTPUT_DIR" "" ${ARGN}) | |
3 set(FILENAME "${CMAKE_SOURCE_DIR}/${BINFILE}") | |
4 set(ELFNAME "${CMAKE_CURRENT_BINARY_DIR}/${BINFILE}.o") | |
5 #message("FILENAME ${FILENAME} ELFNAME ${ELFNAME}") | |
6 | |
7 # Not sure why but we can't depend directly, have to create this intermediary | |
8 # Copied idea from pico_generate_pio_header | |
9 get_filename_component(BIN_GEN_TARGET ${BINFILE} NAME_WE) | |
10 set(BIN_GEN_TARGET "${TARGET}_${BIN_GEN_TARGET}") | |
11 add_custom_target(${BIN_GEN_TARGET} DEPENDS ${ELFNAME}) | |
12 | |
13 # Create symbol name for bin file | |
14 string(MAKE_C_IDENTIFIER ${BINFILE} BIN_SYMNAME) | |
15 #message("BINFILE ${BINFILE} BIN_SYMNAME ${BIN_SYMNAME}") | |
16 | |
17 # Get directory name of source file | |
18 # ld will name the symbol based on the full path so we have to mangle it | |
19 get_filename_component(BIN_SRC_DIR ${FILENAME} DIRECTORY) | |
20 string(REPLACE "/" "_" SRC_DIRNAME_MANGLED ${BIN_SRC_DIR}) | |
21 #message("SRC_DIRNAME_MANGLED ${SRC_DIRNAME_MANGLED}") | |
22 | |
23 add_custom_command(OUTPUT ${ELFNAME} | |
24 COMMAND arm-none-eabi-ld -r -b binary -o ${ELFNAME} | |
25 --defsym=${BIN_SYMNAME}_start=_binary_${SRC_DIRNAME_MANGLED}_${BIN_SYMNAME}_start | |
26 --defsym=${BIN_SYMNAME}_size=_binary_${SRC_DIRNAME_MANGLED}_${BIN_SYMNAME}_size | |
27 ${FILENAME} | |
28 DEPENDS ${FILENAME}) | |
29 add_dependencies(${TARGET} ${BIN_GEN_TARGET}) | |
30 | |
31 # Add object file to list of things to be linked | |
32 target_link_libraries(${TARGET} ${CMAKE_CURRENT_BINARY_DIR}/${ELFNAME}) | |
33 endfunction() |