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.
pull/14516/head
Martin Kojtal 2021-04-12 09:53:05 +01:00
parent ed609f57c4
commit b6a90c4ae1
3 changed files with 11 additions and 5 deletions

View File

@ -3,6 +3,8 @@
include(mbed_set_post_build)
set(MBED_POST_BUILD_TFM_DIR "${CMAKE_CURRENT_LIST_DIR}")
#
# Sign TF-M secure and non-secure images and combine them with the bootloader
#
@ -17,7 +19,7 @@ function(mbed_post_build_tfm_sign_image
set(mbed_target_name ${mbed_target})
set(post_build_command
COMMAND ${Python3_EXECUTABLE}
${CMAKE_CURRENT_LIST_DIR}/scripts/generate_mbed_image.py
${MBED_POST_BUILD_TFM_DIR}/generate_mbed_image.py
--tfm-target ${tfm_target}
--target-path ${target_path}
--secure-bin ${secure_bin}

View File

@ -3,6 +3,8 @@
include(mbed_set_post_build)
set(MBED_POST_BUILD_CYPRESS_DIR "${CMAKE_CURRENT_LIST_DIR}")
#
# Merge Cortex-M4 HEX and a Cortex-M0 HEX.
#
@ -20,7 +22,7 @@ function(mbed_post_build_psoc6_merge_hex mbed_target_name)
# Get extra argument as `cortex_m0_hex`
list(GET extra_macro_args 0 cortex_m0_hex)
set(post_build_command
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/PSOC6.py
COMMAND ${Python3_EXECUTABLE} ${MBED_POST_BUILD_CYPRESS_DIR}/PSOC6.py
merge
--elf ${CMAKE_BINARY_DIR}/$<TARGET_PROPERTY:mbed-post-build-bin-${mbed_target_name},application>.elf
--m4hex ${CMAKE_BINARY_DIR}/$<TARGET_PROPERTY:mbed-post-build-bin-${mbed_target_name},application>.hex
@ -28,7 +30,7 @@ function(mbed_post_build_psoc6_merge_hex mbed_target_name)
)
else()
set(post_build_command
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/PSOC6.py
COMMAND ${Python3_EXECUTABLE} ${MBED_POST_BUILD_CYPRESS_DIR}/PSOC6.py
merge
--elf ${CMAKE_BINARY_DIR}/$<TARGET_PROPERTY:mbed-post-build-bin-${mbed_target_name},application>.elf
--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
find_package(Python3)
set(post_build_command
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/PSOC6.py
COMMAND ${Python3_EXECUTABLE} ${MBED_POST_BUILD_CYPRESS_DIR}/PSOC6.py
sign
--build-dir ${CMAKE_BINARY_DIR}
--m0hex-filename ${m0hex_filename}

View File

@ -3,6 +3,8 @@
include(mbed_set_post_build)
set(MBED_POST_BUILD_NXP_DIR "${CMAKE_CURRENT_LIST_DIR}")
#
# Patch an LPC target vector table in the binary file.
#
@ -10,7 +12,7 @@ function(mbed_post_build_lpc_patch_vtable mbed_target_name)
find_package(Python3)
set(post_build_command
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/LPC.py
COMMAND ${Python3_EXECUTABLE} ${MBED_POST_BUILD_NXP_DIR}/LPC.py
${CMAKE_BINARY_DIR}/$<TARGET_PROPERTY:mbed-post-build-bin-${mbed_target_name},application>.bin
)