Skip to content

Commit 5ae8e0e

Browse files
committed
replace file(copy by cmake -E copy
1 parent d4062f5 commit 5ae8e0e

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

tools/cmake/mbed_set_post_build.cmake

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,20 @@ function(mbed_set_post_build target)
8888
# executable suffix for all toolchains as CMake hardcodes the name of the
8989
# diagnostic output file for some toolchains.
9090

91-
# COPY_FILE could be used with cmake >=3.21
92-
file(COPY_FILE
93-
"${CMAKE_CURRENT_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.map"
94-
"${CMAKE_CURRENT_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.map.old"
95-
RESULT 0)
91+
# copy mapfile .map to .map.old for ram/rom statistics diff in memap.py
92+
if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.map)
93+
add_custom_command(
94+
TARGET
95+
${target}
96+
PRE_BUILD
97+
COMMAND
98+
${CMAKE_COMMAND} -E rename "${CMAKE_CURRENT_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.map" "${CMAKE_CURRENT_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.map.old"
99+
COMMENT
100+
"executable:"
101+
VERBATIM
102+
)
103+
endif()
104+
96105
mbed_configure_memory_map(${target} "${CMAKE_CURRENT_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.map")
97106
mbed_validate_application_profile(${target})
98107
mbed_generate_bin_hex(${target})

0 commit comments

Comments
 (0)