Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Linker Map Generation For macOS #30

Merged
merged 1 commit into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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