Skip to content

Commit 1c2974b

Browse files
authored
Add feature for auto search of upload method config for custom targets (ARMmbed#250)
* Update app.cmake Add possibility to use upload config also for custom targes * Update app.cmake
1 parent 7501ee7 commit 1c2974b

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

tools/cmake/app.cmake

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,30 @@ endif()
7575
# Load upload method configuration defaults for this target.
7676
# Loading the settings here makes sure they are set at global scope, and also makes sure that
7777
# the user can override them by changing variable values after including app.cmake.
78-
set(EXPECTED_MBED_UPLOAD_CFG_FILE_PATH targets/upload_method_cfg/${MBED_TARGET}.cmake)
79-
if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/../../${EXPECTED_MBED_UPLOAD_CFG_FILE_PATH})
80-
message(STATUS "Mbed: Loading default upload method configuration from ${EXPECTED_MBED_UPLOAD_CFG_FILE_PATH}")
81-
include(${CMAKE_CURRENT_LIST_DIR}/../../${EXPECTED_MBED_UPLOAD_CFG_FILE_PATH})
78+
#
79+
# default expected paths
80+
set(EXPECTED_CUSTOM_UPLOAD_CFG_FILE_PATH ${CMAKE_SOURCE_DIR}/custom_targets/upload_method_cfg/${MBED_TARGET}.cmake)
81+
set(EXPECTED_MBED_UPLOAD_CFG_FILE_PATH ${CMAKE_SOURCE_DIR}/mbed-os/targets/upload_method_cfg/${MBED_TARGET}.cmake)
82+
83+
# check if a custom upload config path is defined in top lvl cmake
84+
if((DEFINED CUSTOM_UPLOAD_CFG_PATH))
85+
if(EXISTS ${CUSTOM_UPLOAD_CFG_PATH})
86+
include(${CUSTOM_UPLOAD_CFG_PATH})
87+
message(STATUS "Mbed: Custom upload config included from ${CUSTOM_UPLOAD_CFG_PATH}")
88+
else()
89+
message(FATAL_ERROR "Mbed: Custom upload config is defined but files was not found here - ${CUSTOM_UPLOAD_CFG_PATH}")
90+
endif()
91+
92+
# check if a custom upload config is present in custom_targets/YOUR_TARGET folder
93+
elseif(EXISTS ${EXPECTED_CUSTOM_UPLOAD_CFG_FILE_PATH})
94+
include(${EXPECTED_CUSTOM_UPLOAD_CFG_FILE_PATH})
95+
message(STATUS "Mbed: Custom upload config included from ${EXPECTED_CUSTOM_UPLOAD_CFG_FILE_PATH}")
96+
97+
# check for build in upload config
98+
elseif(EXISTS ${EXPECTED_MBED_UPLOAD_CFG_FILE_PATH})
99+
include(${EXPECTED_MBED_UPLOAD_CFG_FILE_PATH})
100+
message(STATUS "Mbed: Loading default upload method configuration from ${EXPECTED_MBED_UPLOAD_CFG_FILE_PATH}")
82101
else()
83102
message(STATUS "Mbed: Target does not have any upload method configuration. 'make flash-' commands will not be available unless configured by the upper-level project.")
84103
set(UPLOAD_METHOD_DEFAULT "NONE")
85-
endif()
104+
endif()

0 commit comments

Comments
 (0)