Skip to content

Commit b6a90c4

Browse files
committed
CMake: fix for CMAKE_CURRENT_LIST_DIR in functions
CMAKE_CURRENT_LIST_DIR behaves differently in functions. We store it in the CMakeLists itself, so anyone calling a function would get the actual list dir where the scripts are. To illustrate: if I call a function from src/CMakelists.txt, function located in src/scripts, `CMAKE_CURRENT_LIST_DIR` in the function would point to the src/ folder but not to src/scripts.
1 parent ed609f5 commit b6a90c4

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/scripts/mbed_set_post_build_tfm.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
include(mbed_set_post_build)
55

6+
set(MBED_POST_BUILD_TFM_DIR "${CMAKE_CURRENT_LIST_DIR}")
7+
68
#
79
# Sign TF-M secure and non-secure images and combine them with the bootloader
810
#
@@ -17,7 +19,7 @@ function(mbed_post_build_tfm_sign_image
1719
set(mbed_target_name ${mbed_target})
1820
set(post_build_command
1921
COMMAND ${Python3_EXECUTABLE}
20-
${CMAKE_CURRENT_LIST_DIR}/scripts/generate_mbed_image.py
22+
${MBED_POST_BUILD_TFM_DIR}/generate_mbed_image.py
2123
--tfm-target ${tfm_target}
2224
--target-path ${target_path}
2325
--secure-bin ${secure_bin}

targets/TARGET_Cypress/scripts/mbed_set_post_build_cypress.cmake

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
include(mbed_set_post_build)
55

6+
set(MBED_POST_BUILD_CYPRESS_DIR "${CMAKE_CURRENT_LIST_DIR}")
7+
68
#
79
# Merge Cortex-M4 HEX and a Cortex-M0 HEX.
810
#
@@ -20,15 +22,15 @@ function(mbed_post_build_psoc6_merge_hex mbed_target_name)
2022
# Get extra argument as `cortex_m0_hex`
2123
list(GET extra_macro_args 0 cortex_m0_hex)
2224
set(post_build_command
23-
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/PSOC6.py
25+
COMMAND ${Python3_EXECUTABLE} ${MBED_POST_BUILD_CYPRESS_DIR}/PSOC6.py
2426
merge
2527
--elf ${CMAKE_BINARY_DIR}/$<TARGET_PROPERTY:mbed-post-build-bin-${mbed_target_name},application>.elf
2628
--m4hex ${CMAKE_BINARY_DIR}/$<TARGET_PROPERTY:mbed-post-build-bin-${mbed_target_name},application>.hex
2729
--m0hex ${cortex_m0_hex}
2830
)
2931
else()
3032
set(post_build_command
31-
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/PSOC6.py
33+
COMMAND ${Python3_EXECUTABLE} ${MBED_POST_BUILD_CYPRESS_DIR}/PSOC6.py
3234
merge
3335
--elf ${CMAKE_BINARY_DIR}/$<TARGET_PROPERTY:mbed-post-build-bin-${mbed_target_name},application>.elf
3436
--m4hex ${CMAKE_BINARY_DIR}/$<TARGET_PROPERTY:mbed-post-build-bin-${mbed_target_name},application>.hex
@@ -54,7 +56,7 @@ function(mbed_post_build_psoc6_sign_image
5456
find_package(Python3)
5557

5658
set(post_build_command
57-
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/PSOC6.py
59+
COMMAND ${Python3_EXECUTABLE} ${MBED_POST_BUILD_CYPRESS_DIR}/PSOC6.py
5860
sign
5961
--build-dir ${CMAKE_BINARY_DIR}
6062
--m0hex-filename ${m0hex_filename}

targets/TARGET_NXP/scripts/mbed_set_post_build_nxp.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33

44
include(mbed_set_post_build)
55

6+
set(MBED_POST_BUILD_NXP_DIR "${CMAKE_CURRENT_LIST_DIR}")
7+
68
#
79
# Patch an LPC target vector table in the binary file.
810
#
911
function(mbed_post_build_lpc_patch_vtable mbed_target_name)
1012
find_package(Python3)
1113

1214
set(post_build_command
13-
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/LPC.py
15+
COMMAND ${Python3_EXECUTABLE} ${MBED_POST_BUILD_NXP_DIR}/LPC.py
1416
${CMAKE_BINARY_DIR}/$<TARGET_PROPERTY:mbed-post-build-bin-${mbed_target_name},application>.bin
1517
)
1618

0 commit comments

Comments
 (0)