From 073ae1d3438b183e21f6a2fd55bf298ee44b286e Mon Sep 17 00:00:00 2001 From: Rajkumar Kanagaraj <45570536+rajkan01@users.noreply.github.com> Date: Fri, 6 Nov 2020 17:16:42 +0000 Subject: [PATCH] CMake: Validate selected application profile (#13856) Check if the selected application profile is supported by the selected Mbed Target --- CMakeLists.txt | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f0ad1d4d7..b3c7d3f8c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -205,7 +205,7 @@ function(mbed_generate_map_file target) TARGET ${target} POST_BUILD - COMMAND ${Python3_EXECUTABLE} ${MBED_ROOT}/tools/memap.py -t ${MBED_TOOLCHAIN} ${CMAKE_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.map + COMMAND ${Python3_EXECUTABLE} ${MBED_PATH}/tools/memap.py -t ${MBED_TOOLCHAIN} ${CMAKE_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.map WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMENT @@ -214,9 +214,27 @@ function(mbed_generate_map_file target) endfunction() # -# Generate executables +# Validate selected application profile. # -function(mbed_generate_executable target) +function(mbed_validate_application_profile target) + get_target_property(app_link_libraries ${target} LINK_LIBRARIES) + string(FIND "${app_link_libraries}" "mbed-baremetal" string_found_position) + if(${string_found_position} GREATER_EQUAL 0) + if(NOT "bare-metal" IN_LIST MBED_TARGET_SUPPORTED_APPLICATION_PROFILES) + message(FATAL_ERROR + "Use full profile as baremetal profile is not supported for this Mbed target") + endif() + elseif(NOT "full" IN_LIST MBED_TARGET_SUPPORTED_APPLICATION_PROFILES) + message(FATAL_ERROR + "The full profile is not supported for this Mbed target") + endif() +endfunction() + +# +# Set post build operations +# +function(mbed_set_post_build target) + mbed_validate_application_profile(${target}) mbed_generate_bin_hex(${target}) mbed_generate_map_file(${target}) endfunction()