Skip to content

Commit ba1e7b5

Browse files
authored
Merge pull request #14272 from ladislas/ladislas/feature/cmake-current-binary-dir
Change CMAKE_BINARY_DIR to CMAKE_CURRENT_BINARY_DIR
2 parents 8321943 + 5a879c6 commit ba1e7b5

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

CMakeLists.txt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ function(mbed_configure_app_target target)
159159
message(${target})
160160
target_link_options(mbed-core
161161
INTERFACE
162-
"-Wl,-Map=${CMAKE_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.map"
162+
"-Wl,-Map=${CMAKE_CURRENT_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.map"
163163
)
164164
endif()
165165
endfunction()
@@ -171,18 +171,18 @@ function(mbed_generate_bin_hex target)
171171
get_property(elf_to_bin GLOBAL PROPERTY ELF2BIN)
172172
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
173173
set(CMAKE_POST_BUILD_COMMAND
174-
COMMAND ${elf_to_bin} -O binary $<TARGET_FILE:${target}> ${CMAKE_BINARY_DIR}/${target}.bin
175-
COMMAND ${CMAKE_COMMAND} -E echo "-- built: ${CMAKE_BINARY_DIR}/${target}.bin"
176-
COMMAND ${elf_to_bin} -O ihex $<TARGET_FILE:${target}> ${CMAKE_BINARY_DIR}/${target}.hex
177-
COMMAND ${CMAKE_COMMAND} -E echo "-- built: ${CMAKE_BINARY_DIR}/${target}.hex"
174+
COMMAND ${elf_to_bin} -O binary $<TARGET_FILE:${target}> ${CMAKE_CURRENT_BINARY_DIR}/${target}.bin
175+
COMMAND ${CMAKE_COMMAND} -E echo "-- built: ${CMAKE_CURRENT_BINARY_DIR}/${target}.bin"
176+
COMMAND ${elf_to_bin} -O ihex $<TARGET_FILE:${target}> ${CMAKE_CURRENT_BINARY_DIR}/${target}.hex
177+
COMMAND ${CMAKE_COMMAND} -E echo "-- built: ${CMAKE_CURRENT_BINARY_DIR}/${target}.hex"
178178
)
179179
elseif(MBED_TOOLCHAIN STREQUAL "ARM")
180180
get_property(mbed_studio_arm_compiler GLOBAL PROPERTY MBED_STUDIO_ARM_COMPILER)
181181
set(CMAKE_POST_BUILD_COMMAND
182-
COMMAND ${elf_to_bin} ${mbed_studio_arm_compiler} --bin -o ${CMAKE_BINARY_DIR}/${target}.bin $<TARGET_FILE:${target}>
183-
COMMAND ${CMAKE_COMMAND} -E echo "-- built: ${CMAKE_BINARY_DIR}/${target}.bin"
184-
COMMAND ${elf_to_bin} ${mbed_studio_arm_compiler} --i32combined -o ${CMAKE_BINARY_DIR}/${target}.hex $<TARGET_FILE:${target}>
185-
COMMAND ${CMAKE_COMMAND} -E echo "-- built: ${CMAKE_BINARY_DIR}/${target}.hex"
182+
COMMAND ${elf_to_bin} ${mbed_studio_arm_compiler} --bin -o ${CMAKE_CURRENT_BINARY_DIR}/${target}.bin $<TARGET_FILE:${target}>
183+
COMMAND ${CMAKE_COMMAND} -E echo "-- built: ${CMAKE_CURRENT_BINARY_DIR}/${target}.bin"
184+
COMMAND ${elf_to_bin} ${mbed_studio_arm_compiler} --i32combined -o ${CMAKE_CURRENT_BINARY_DIR}/${target}.hex $<TARGET_FILE:${target}>
185+
COMMAND ${CMAKE_COMMAND} -E echo "-- built: ${CMAKE_CURRENT_BINARY_DIR}/${target}.hex"
186186
)
187187
endif()
188188
add_custom_command(
@@ -212,9 +212,9 @@ function(mbed_generate_map_file target)
212212
TARGET
213213
${target}
214214
POST_BUILD
215-
COMMAND ${Python3_EXECUTABLE} ${MBED_PATH}/tools/memap.py -t ${MBED_TOOLCHAIN} ${CMAKE_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.map
215+
COMMAND ${Python3_EXECUTABLE} ${MBED_PATH}/tools/memap.py -t ${MBED_TOOLCHAIN} ${CMAKE_CURRENT_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.map
216216
WORKING_DIRECTORY
217-
${CMAKE_BINARY_DIR}
217+
${CMAKE_CURRENT_BINARY_DIR}
218218
COMMENT
219219
"Displaying memory map for ${target}"
220220
)

tools/cmake/set_linker_script.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Preprocesses and sets the linker script for an Mbed target.
66
#
77
function(mbed_set_linker_script input_target raw_linker_script_path)
8-
set(LINKER_SCRIPT_PATH ${CMAKE_BINARY_DIR}/${input_target}.link_script.ld)
8+
set(LINKER_SCRIPT_PATH ${CMAKE_CURRENT_BINARY_DIR}/${input_target}.link_script.ld)
99
# To avoid path limits on Windows, we create a "response file" and set the path to it as a
1010
# global property. We need this solely to pass the compile definitions to GCC's preprocessor,
1111
# so it can expand any macro definitions in the linker script.

tools/cmake/toolchain.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ function(mbed_generate_options_for_linker target definitions_file)
1919
set(_compile_definitions
2020
"$<$<BOOL:${_compile_definitions}>:-D$<JOIN:${_compile_definitions}, -D>>"
2121
)
22-
file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/compile_time_defs.txt" CONTENT "${_compile_definitions}\n")
23-
set(${definitions_file} @${CMAKE_BINARY_DIR}/compile_time_defs.txt PARENT_SCOPE)
22+
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/compile_time_defs.txt" CONTENT "${_compile_definitions}\n")
23+
set(${definitions_file} @${CMAKE_CURRENT_BINARY_DIR}/compile_time_defs.txt PARENT_SCOPE)
2424
endfunction()
2525
# Set the system processor depending on the CPU core type
2626
if (MBED_CPU_CORE STREQUAL Cortex-A9)

0 commit comments

Comments
 (0)