Skip to content

Commit

Permalink
Merge pull request #30 from All-Your-Locks-Are-Belong-To-Us/fix/linke…
Browse files Browse the repository at this point in the history
…r-map-generation

Fix Linker Map Generation For macOS
  • Loading branch information
felix-gohla authored Aug 9, 2022
2 parents 6ce6437 + 1e9b6c2 commit 7597dc1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
12 changes: 12 additions & 0 deletions cmake/linker-map.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
set(command ${CMAKE_C_COMPILER} ${flags} -Wl,--version)


function(add_linker_map_for_target TARGET)
if (APPLE)
# LLVM only understands this flag.
# The map output differs from GNU ld.
target_link_options(${TARGET} PRIVATE "-Wl,-map,${TARGET}.map")
else()
target_link_options(${TARGET} PRIVATE "-Wl,-Map=${TARGET}.map")
endif()
endfunction()
5 changes: 3 additions & 2 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
include(../cmake/linker-map.cmake)
#######################################
# NFC example

add_executable(nfc nfc.c)
target_link_options(nfc PRIVATE "-Wl,-Map=nfc.map")
add_linker_map_for_target(nfc)
target_link_libraries(nfc ${PRODUCT_NAME})

add_executable(nfc_simulator nfc_simulator.c)
target_link_options(nfc_simulator PRIVATE "-Wl,-Map=nfc.map")
add_linker_map_for_target(nfc_simulator)
target_link_libraries(nfc_simulator ${PRODUCT_NAME})

#######################################
Expand Down
4 changes: 3 additions & 1 deletion examples/measurements/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
include(../../cmake/linker-map.cmake)

set(measurement_dependencies gpio.c)

function(add_measurement name)
add_executable(${name} "${name}.c" ${measurement_dependencies})
target_link_options(${name} PRIVATE "-Wl,-Map=${name}.map")
add_linker_map_for_target(${name})
target_link_libraries(${name} ${PRODUCT_NAME})
endfunction()

Expand Down

0 comments on commit 7597dc1

Please sign in to comment.