Skip to content

CMake: remove MBED_PATH and use <PROJECT-NAME>_SOURCE_DIR/MODULE_PATH instead #14516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@
cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR)

include(${MBED_CONFIG_PATH}/mbed_config.cmake)
include(tools/cmake/set_linker_script.cmake)
include(mbed_set_linker_script)

project(mbed-os)

# Add all paths to the list files within Mbed OS
list(APPEND CMAKE_MODULE_PATH
"${mbed-os_SOURCE_DIR}/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/scripts;${mbed-os_SOURCE_DIR}/targets/TARGET_Cypress/scripts;${mbed-os_SOURCE_DIR}/targets/TARGET_NXP/scripts"
)

add_library(mbed-core INTERFACE)

Expand Down Expand Up @@ -214,7 +221,7 @@ function(mbed_generate_map_file target)
TARGET
${target}
POST_BUILD
COMMAND ${Python3_EXECUTABLE} ${MBED_PATH}/tools/memap.py -t ${MBED_TOOLCHAIN} ${CMAKE_CURRENT_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.map
COMMAND ${Python3_EXECUTABLE} ${mbed-os_SOURCE_DIR}/tools/memap.py -t ${MBED_TOOLCHAIN} ${CMAKE_CURRENT_BINARY_DIR}/${target}${CMAKE_EXECUTABLE_SUFFIX}.map
WORKING_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}
COMMENT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ target_sources(mbed-psa
src/tfm_platform_ipc_api.c
src/tfm_ps_ipc_api.c
)

Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Copyright (c) 2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

include(${MBED_PATH}/tools/cmake/mbed_set_post_build.cmake)
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
Expand All @@ -17,7 +19,7 @@ function(mbed_post_build_tfm_sign_image
set(mbed_target_name ${mbed_target})
set(post_build_command
COMMAND ${Python3_EXECUTABLE}
${MBED_PATH}/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/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}
Expand Down
3 changes: 2 additions & 1 deletion targets/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (c) 2020-2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
include(../tools/cmake/set_linker_script.cmake)

include(mbed_set_linker_script)

add_subdirectory(TARGET_Ambiq_Micro EXCLUDE_FROM_ALL)
add_subdirectory(TARGET_Analog_Devices EXCLUDE_FROM_ALL)
Expand Down
18 changes: 10 additions & 8 deletions targets/TARGET_ARM_SSG/TARGET_MUSCA_B1/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
# Copyright (c) 2020-2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

include(${MBED_PATH}/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/scripts/mbed_set_post_build_tfm.cmake)
if("TFM" IN_LIST MBED_TARGET_LABELS)
include(mbed_set_post_build_tfm)

mbed_post_build_tfm_sign_image(
ARM_MUSCA_B1
musca_b1
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/tfm_s.bin
)
endif()

add_library(mbed-arm-musca-b1 INTERFACE)

Expand Down Expand Up @@ -54,10 +63,3 @@ target_link_libraries(mbed-arm-musca-b1
${CMAKE_CURRENT_SOURCE_DIR}/s_veneers.o
mbed-arm-ssg
)

mbed_post_build_tfm_sign_image(
ARM_MUSCA_B1
musca_b1
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/tfm_s.bin
)
18 changes: 10 additions & 8 deletions targets/TARGET_ARM_SSG/TARGET_MUSCA_S1/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
# Copyright (c) 2020-2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

include(${MBED_PATH}/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/scripts/mbed_set_post_build_tfm.cmake)
if("TFM" IN_LIST MBED_TARGET_LABELS)
include(mbed_set_post_build_tfm)

mbed_post_build_tfm_sign_image(
ARM_MUSCA_S1
musca_s1
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/tfm_s.bin
)
endif()

add_library(mbed-arm-musca-s1 INTERFACE)

Expand Down Expand Up @@ -60,10 +69,3 @@ target_link_libraries(mbed-arm-musca-s1
${CMAKE_CURRENT_SOURCE_DIR}/s_veneers.o
mbed-arm-ssg
)

mbed_post_build_tfm_sign_image(
ARM_MUSCA_S1
musca_s1
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/tfm_s.bin
)
1 change: 1 addition & 0 deletions targets/TARGET_Cypress/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ target_compile_definitions(mbed-cy-external-wifi-fw
"CY_STORAGE_WIFI_DATA_OUTPUT=cy_xip"
"CY_EXT_WIFI_FW_STORAGE=QSPIF"
)

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) 2020-2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

include(${MBED_PATH}/targets/TARGET_Cypress/scripts/mbed_set_post_build_cypress.cmake)
include(mbed_set_post_build_cypress)

add_library(mbed-cy8ckit064b0s2-4343w-bsp-design-modus INTERFACE)
target_include_directories(mbed-cy8ckit064b0s2-4343w-bsp-design-modus
Expand Down Expand Up @@ -86,5 +86,5 @@ mbed_post_build_psoc6_sign_image(
"single_image"
"1"
"16"
"${MBED_PATH}/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT064B0S2_4343W/device/COMPONENT_CM4/hex/psoc6_02_cm0p_secure.hex"
"${CMAKE_CURRENT_SOURCE_DIR}/device/COMPONENT_CM4/hex/psoc6_02_cm0p_secure.hex"
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) 2020-2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

include(${MBED_PATH}/targets/TARGET_Cypress/scripts/mbed_set_post_build_cypress.cmake)
include(mbed_set_post_build_cypress)

add_library(mbed-cysbsyskit-01-bsp-design-modus INTERFACE)
target_include_directories(mbed-cysbsyskit-01-bsp-design-modus
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) 2020-2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

include(${MBED_PATH}/targets/TARGET_Cypress/scripts/mbed_set_post_build_cypress.cmake)
include(mbed_set_post_build_cypress)

add_library(mbed-cytfm-064b0s2-4343w-bsp-design-modus INTERFACE)
target_include_directories(mbed-cytfm-064b0s2-4343w-bsp-design-modus
Expand Down Expand Up @@ -79,5 +79,5 @@ mbed_post_build_psoc6_sign_image(
"multi_image"
"1"
"16"
${MBED_PATH}/targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CYTFM_064B0S2_4343W/COMPONENT_TFM_S_FW/tfm_s.hex
${CMAKE_CURRENT_SOURCE_DIR}/COMPONENT_TFM_S_FW/tfm_s.hex
)
10 changes: 6 additions & 4 deletions targets/TARGET_Cypress/scripts/mbed_set_post_build_cypress.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Copyright (c) 2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

include(${MBED_PATH}/tools/cmake/mbed_set_post_build.cmake)
include(mbed_set_post_build)

set(MBED_POST_BUILD_CYPRESS_DIR "${CMAKE_CURRENT_LIST_DIR}")

#
# Merge Cortex-M4 HEX and a Cortex-M0 HEX.
Expand All @@ -20,15 +22,15 @@ 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} ${MBED_PATH}/targets/TARGET_Cypress/scripts/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
--m0hex ${cortex_m0_hex}
)
else()
set(post_build_command
COMMAND ${Python3_EXECUTABLE} ${MBED_PATH}/targets/TARGET_Cypress/scripts/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
Expand All @@ -54,7 +56,7 @@ function(mbed_post_build_psoc6_sign_image
find_package(Python3)

set(post_build_command
COMMAND ${Python3_EXECUTABLE} ${MBED_PATH}/targets/TARGET_Cypress/scripts/PSOC6.py
COMMAND ${Python3_EXECUTABLE} ${MBED_POST_BUILD_CYPRESS_DIR}/PSOC6.py
sign
--build-dir ${CMAKE_BINARY_DIR}
--m0hex-filename ${m0hex_filename}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) 2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

include(${MBED_PATH}/targets/TARGET_NXP/scripts/mbed_set_post_build_nxp.cmake)
include(mbed_set_post_build_nxp)

add_library(mbed-lpc11xx INTERFACE)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) 2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

include(${MBED_PATH}/targets/TARGET_NXP/scripts/mbed_set_post_build_nxp.cmake)
include(mbed_set_post_build_nxp)

add_library(mbed-arch-pro INTERFACE)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) 2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

include(${MBED_PATH}/targets/TARGET_NXP/scripts/mbed_set_post_build_nxp.cmake)
include(mbed_set_post_build_nxp)

add_library(mbed-mbed-lpc1768 INTERFACE)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) 2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

include(${MBED_PATH}/targets/TARGET_NXP/scripts/mbed_set_post_build_nxp.cmake)
include(mbed_set_post_build_nxp)

if(${MBED_TOOLCHAIN} STREQUAL "ARM")
set(STARTUP_FILE TOOLCHAIN_ARM_STD/startup_LPC54114_cm4.S)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) 2020-2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

include(${MBED_PATH}/targets/TARGET_NXP/scripts/mbed_set_post_build_nxp.cmake)
include(mbed_set_post_build_nxp)

add_subdirectory(TARGET_FF_LPC546XX EXCLUDE_FROM_ALL)
add_subdirectory(TARGET_LPCXpresso EXCLUDE_FROM_ALL)
Expand Down
6 changes: 4 additions & 2 deletions targets/TARGET_NXP/scripts/mbed_set_post_build_nxp.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Copyright (c) 2021 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

include(${MBED_PATH}/tools/cmake/mbed_set_post_build.cmake)
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.
Expand All @@ -10,7 +12,7 @@ function(mbed_post_build_lpc_patch_vtable mbed_target_name)
find_package(Python3)

set(post_build_command
COMMAND ${Python3_EXECUTABLE} ${MBED_PATH}/targets/TARGET_NXP/scripts/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
)

Expand Down
9 changes: 6 additions & 3 deletions tools/cmake/app.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

# Add our CMake list files to CMake default module path
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})

find_program(CCACHE "ccache")
if(CCACHE)
set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE})
Expand All @@ -12,11 +15,11 @@ include(${MBED_CONFIG_PATH}/mbed_config.cmake)
# Load toolchain file
if(NOT CMAKE_TOOLCHAIN_FILE OR MBED_TOOLCHAIN_FILE_USED)
set(MBED_TOOLCHAIN_FILE_USED TRUE CACHE INTERNAL "")
include(${MBED_PATH}/tools/cmake/toolchain.cmake)
include(mbed_toolchain)
endif()

# Specify available build profiles and add options for the selected build profile
include(${MBED_PATH}/tools/cmake/profile.cmake)
include(mbed_profile)

enable_language(C CXX ASM)

Expand All @@ -26,7 +29,7 @@ set(CMAKE_EXECUTABLE_SUFFIX .elf)

# Find Python
find_package(Python3 COMPONENTS Interpreter)
include(${CMAKE_CURRENT_LIST_DIR}/CheckPythonPackage.cmake)
include(CheckPythonPackage)

# Check python packages from requirements.txt
file(STRINGS ${CMAKE_CURRENT_LIST_DIR}/requirements.txt PYTHON_REQUIREMENTS)
Expand Down
2 changes: 1 addition & 1 deletion tools/cmake/mbed_greentea.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

set(MBED_CONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR} CACHE INTERNAL "")

include(${MBED_PATH}/tools/cmake/app.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/app.cmake)

# CMake Macro for generalizing CMake configuration across the greentea test suite with configurable parameters
# Macro args:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ else()
endif()
endif()

include(${MBED_PATH}/tools/cmake/profiles/${LOWERCASE_CMAKE_BUILD_TYPE}.cmake)
include(profiles/${LOWERCASE_CMAKE_BUILD_TYPE})
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ set(link_options "")
set(common_options "")
set(c_cxx_compile_options "") # compile options only for C/CXX
set(asm_compile_options "") # compile options only for ASM
include(${MBED_PATH}/tools/cmake/toolchains/${MBED_TOOLCHAIN}.cmake)
include(${MBED_PATH}/tools/cmake/cores/${MBED_CPU_CORE}.cmake)

include(toolchains/${MBED_TOOLCHAIN})
include(cores/${MBED_CPU_CORE})

#converts a list into a string with each of its elements seperated by a space
macro(list_to_space_separated OUTPUT_VAR)# 2nd arg: LIST...
Expand Down