mirror of https://github.com/ARMmbed/mbed-os.git
Switch mbed-baremetal and mbed-os to be OBJECT libraries. Can reuse the existing create_distro function for this.
parent
807fd79651
commit
8080220a40
|
@ -40,22 +40,13 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(mbed-core INTERFACE)
|
# These targets are made visible here so their source files which
|
||||||
|
# are spread in different directories can be referenced and can be linked against
|
||||||
|
# by libraries that depend on them.
|
||||||
|
add_library(mbed-device_key INTERFACE)
|
||||||
|
add_library(mbed-rtos INTERFACE) # Collects source files and flags that are in mbed-os but not mbed-baremetal
|
||||||
|
add_library(mbed-core INTERFACE) # Collects source files and flags common to mbed-baremetal and mbed-os
|
||||||
|
|
||||||
add_library(mbed-os INTERFACE)
|
|
||||||
|
|
||||||
target_link_libraries(mbed-os
|
|
||||||
INTERFACE
|
|
||||||
mbed-rtos
|
|
||||||
mbed-core
|
|
||||||
)
|
|
||||||
|
|
||||||
add_library(mbed-baremetal INTERFACE)
|
|
||||||
|
|
||||||
target_link_libraries(mbed-baremetal
|
|
||||||
INTERFACE
|
|
||||||
mbed-core
|
|
||||||
)
|
|
||||||
# Validate selected C library type
|
# Validate selected C library type
|
||||||
# The C library type selected has to match the library that the target can support
|
# The C library type selected has to match the library that the target can support
|
||||||
if(${CMAKE_CROSSCOMPILING})
|
if(${CMAKE_CROSSCOMPILING})
|
||||||
|
@ -153,13 +144,6 @@ target_include_directories(mbed-core
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
# These targets are made visible here so their source files which
|
|
||||||
# are spread in different directories can be referenced and can be linked against
|
|
||||||
# by libraries that depend on them.
|
|
||||||
# TODO CMake: Should the source files be moved?
|
|
||||||
add_library(mbed-device_key INTERFACE)
|
|
||||||
add_library(mbed-rtos INTERFACE)
|
|
||||||
|
|
||||||
# Include targets/ first, because any post-build hook needs to be defined
|
# Include targets/ first, because any post-build hook needs to be defined
|
||||||
# before other parts of Mbed OS can add greentea tests which require
|
# before other parts of Mbed OS can add greentea tests which require
|
||||||
# mbed_set_post_build().
|
# mbed_set_post_build().
|
||||||
|
@ -187,10 +171,16 @@ if(${CMAKE_CROSSCOMPILING})
|
||||||
string(TOLOWER ${MBED_TARGET} MBED_TARGET_CONVERTED)
|
string(TOLOWER ${MBED_TARGET} MBED_TARGET_CONVERTED)
|
||||||
string(REPLACE "_" "-" MBED_TARGET_CONVERTED ${MBED_TARGET_CONVERTED})
|
string(REPLACE "_" "-" MBED_TARGET_CONVERTED ${MBED_TARGET_CONVERTED})
|
||||||
string(PREPEND MBED_TARGET_CONVERTED "mbed-")
|
string(PREPEND MBED_TARGET_CONVERTED "mbed-")
|
||||||
|
|
||||||
target_link_libraries(mbed-core INTERFACE ${MBED_TARGET_CONVERTED})
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Core Mbed OS library
|
||||||
|
# mbed-baremetal contains baremetal sources + target sources + target compile flags.
|
||||||
|
# mbed-os will be a superset of mbed-baremetal, also containing the RTOS sources and RTOS flags.
|
||||||
|
# Note that many different source files will compile differently depending on if the RTOS is in use.
|
||||||
|
# So, it's needed to compile the core sources twice, once for RTOS and once for non-RTOS.
|
||||||
|
mbed_create_distro(mbed-baremetal mbed-core ${MBED_TARGET_CONVERTED})
|
||||||
|
mbed_create_distro(mbed-os mbed-core mbed-rtos ${MBED_TARGET_CONVERTED})
|
||||||
|
|
||||||
# Ninja requires to be forced for response files
|
# Ninja requires to be forced for response files
|
||||||
if ("${CMAKE_GENERATOR}" MATCHES "Ninja")
|
if ("${CMAKE_GENERATOR}" MATCHES "Ninja")
|
||||||
# known issue ARMClang and Ninja with response files for windows
|
# known issue ARMClang and Ninja with response files for windows
|
||||||
|
|
|
@ -32,8 +32,7 @@ endfunction(copy_append_property)
|
||||||
# Create a "distribution" of Mbed OS containing the base Mbed and certain modules.
|
# Create a "distribution" of Mbed OS containing the base Mbed and certain modules.
|
||||||
# This distribution only needs to be compiled once and can be referenced in an arbitrary amount of targets.
|
# This distribution only needs to be compiled once and can be referenced in an arbitrary amount of targets.
|
||||||
function(mbed_create_distro NAME) # ARGN: modules...
|
function(mbed_create_distro NAME) # ARGN: modules...
|
||||||
add_library(${NAME} OBJECT)
|
add_library(${NAME} OBJECT EXCLUDE_FROM_ALL)
|
||||||
mbed_configure_app_target(${NAME})
|
|
||||||
|
|
||||||
# First link as private dependencies
|
# First link as private dependencies
|
||||||
target_link_libraries(${NAME} PRIVATE ${ARGN})
|
target_link_libraries(${NAME} PRIVATE ${ARGN})
|
||||||
|
|
Loading…
Reference in New Issue