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

Generate .map file. #35

Open
Cierpliwy opened this issue Jun 19, 2020 · 1 comment
Open

Generate .map file. #35

Cierpliwy opened this issue Jun 19, 2020 · 1 comment

Comments

@Cierpliwy
Copy link
Contributor

Add an option to the main target to generate .map file for the project.

@gudnimg
Copy link

gudnimg commented Feb 16, 2021

I do it like this in my project:

I am using CMake 3.19.4 and cannot guarantee this will work back to CMake 3.14.

function(nrf5_target target)
    # .... some code above
        # Generate linker map file
        target_linker_map(${target})
    # .... some code below
endfunction()

function(target_linker_map target)
    set(GEN_MAP_FILE "-Wl,-Map,")
    get_target_property(map_dir ${target} BINARY_DIR) # Read which folder target is defined
    target_link_options(${target} PRIVATE ${GEN_MAP_FILE}${map_dir}/${target}.map) # place .map file is same folder as target

    # allow ninja clean command to remove file
    set_target_properties(${target} PROPERTIES
        ADDITIONAL_CLEAN_FILES ${target}.map)
endfunction()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants