CMake: expose what core needs from a target via MBED_TARGET_CONVERTED-core

Use `${MBED_TARGET_CONVERTED}-core` target for exposing cmsis/device headers to the core. This breaks
the circular dependency between core and  targets.

I also attempt to break building objects per each level in targets hieararchy. The top level target - public facing target, needs to gather sources and create object library.
pull/14427/head
Martin Kojtal 2021-02-23 15:54:11 +00:00
parent ab0be209f0
commit d6041a00de
4 changed files with 35 additions and 9 deletions

View File

@ -140,6 +140,10 @@ add_subdirectory(drivers)
add_subdirectory(hal)
add_subdirectory(platform)
add_subdirectory(rtos)
# Target provides includes for core to find device.h/cmsis.h or nvic related files
add_library(${MBED_TARGET_CONVERTED}-core INTERFACE)
add_subdirectory(targets)
# The directories below contain optional target libraries
@ -152,7 +156,8 @@ add_subdirectory(features EXCLUDE_FROM_ALL)
add_subdirectory(cmsis/CMSIS_5/CMSIS/RTOS2 EXCLUDE_FROM_ALL)
add_subdirectory(cmsis/device/rtos EXCLUDE_FROM_ALL)
target_link_libraries(mbed-core-obj PRIVATE ${MBED_TARGET_CONVERTED})
# TODO: remove this now
target_link_libraries(mbed-core-obj PRIVATE ${MBED_TARGET_CONVERTED}-core)
#
# Converts output file of `target` to binary file and to Intel HEX file.

View File

@ -8,7 +8,7 @@ add_subdirectory(TARGET_MAX32625 EXCLUDE_FROM_ALL)
add_subdirectory(TARGET_MAX32630 EXCLUDE_FROM_ALL)
add_library(mbed-maxim INTERFACE)
add_library(mbed-maxim-obj OBJECT)
add_library(mbed-maxim-obj INTERFACE)
target_include_directories(mbed-maxim
INTERFACE
@ -16,10 +16,13 @@ target_include_directories(mbed-maxim
)
target_sources(mbed-maxim-obj
PRIVATE
INTERFACE
USBPhy_Maxim.cpp
)
mbed_attach_object_lib_with_interface_lib(mbed-maxim)
target_include_directories(${MBED_TARGET_CONVERTED}-core
INTERFACE
.
)
target_link_libraries(mbed-maxim-obj PRIVATE mbed-cmsis-cortex-m mbed-core)
target_link_libraries(mbed-maxim INTERFACE mbed-cmsis-cortex-m mbed-core)

View File

@ -15,7 +15,7 @@ elseif(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
endif()
add_library(mbed-maxim-max32620c INTERFACE)
add_library(mbed-maxim-max32620c-obj OBJECT)
add_library(mbed-maxim-max32620c-obj INTERFACE)
target_include_directories(mbed-maxim-max32620c
INTERFACE
@ -24,10 +24,20 @@ target_include_directories(mbed-maxim-max32620c
mxc
)
target_include_directories(${MBED_TARGET_CONVERTED}-core
INTERFACE
.
device
mxc
)
target_link_libraries(${MBED_TARGET_CONVERTED}-core INTERFACE mbed-cmsis-cortex-m)
mbed_set_linker_script(mbed-maxim-max32620c ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE})
target_sources(mbed-maxim-max32620c-obj
PRIVATE
INTERFACE
PeripheralPins.c
analogin_api.c
flash_api.c
@ -81,7 +91,7 @@ target_sources(mbed-maxim-max32620c-obj
target_link_libraries(mbed-maxim-max32620c
INTERFACE
mbed-maxim
mbed-cmsis-cortex-m
mbed-core
)
mbed_attach_object_lib_with_interface_lib(mbed-maxim-max32620c)

View File

@ -2,6 +2,7 @@
# SPDX-License-Identifier: Apache-2.0
add_library(mbed-max32620fthr INTERFACE)
add_library(mbed-max32620fthr-obj OBJECT)
target_include_directories(mbed-max32620fthr
INTERFACE
@ -9,3 +10,10 @@ target_include_directories(mbed-max32620fthr
)
target_link_libraries(mbed-max32620fthr INTERFACE mbed-maxim-max32620c)
target_include_directories(${MBED_TARGET_CONVERTED}-core
INTERFACE
.
)
target_sources(mbed-max32620fthr-obj PRIVATE $<TARGET_PROPERTY:mbed-max32620fthr,INTERFACE_SOURCES>)