Commit Graph

34 Commits (f8a02ce5dede9bd4ef7d7e869e845345766dd9c6)

Author SHA1 Message Date
Rajkumar Kanagaraj e7c0d93ad4 CMake: add mbed-os and mbed-baremetal targets
mbed-os consists of mbed-core and mbed-rtos
mbed-baremetal consists of mbed-core

The main change is for mbed-core. Changing from object library to be interface. This way it allows us to do the above to have 2 main targets for users to use.

This should be backward compatible change as mbed-os target we used contains the same files/options as previously set.
2020-11-06 17:25:22 +00:00
Rajkumar Kanagaraj d2be577b01 CMake: split rtos from core target
Add or remove and directories containing source files, header files, and macro definitions that implement RTOS support.
This includes:
- cmsis/CMSIS_5/CMSIS/RTOS2/
- cmsis/device/rtos/
- rtos/source/ConditionVariable.cpp
- rtos/source/Thread.cpp
2020-11-06 17:25:22 +00:00
Hugues Kamba 2bab2ba038 CMake: Create a mbed-os alias library
This ensures that applications which link with the mbed-os
CMake target still work. We want applications that require the OS
to use the mbed-os CMake target as we will be creating a new one
that will include mbed-core and mbed-rtos.
2020-11-06 17:25:22 +00:00
Hugues Kamba bf84a5b329 CMake: Rename CMake targets
* mbed-os renamed mbed-core
* mbed-os-<COMPONENT> renamed mbed-<COMPONENT>
2020-11-06 17:25:22 +00:00
Martin Kojtal c9cacaf080 CMake: fix application config
These settings like enable_language should be done in the application and just once.
We hit the issue when you expose sources to an app (interface or public), CMake errors as some of the internal settings have not been configured.
2020-11-06 17:25:22 +00:00
Martin Kojtal e0eee75eaf CMake: remove TODO as it is not valid anymore 2020-11-06 17:25:22 +00:00
Martin Kojtal d283e69c99 CMake: fix for Gcc Arm preprocessing linker file
A linker script needs symbols (stack size, app size, etc). They are basic values or defines. Not any array like or string like macros. We should filter these, as they are not valid anyway.

The other option to fix this would be to fix all the macros but I dont think it is needed as these config values won't be used in the linker script anyway.

Not allowed in ld files macros with spaces, like MACRO={0, 2, 3} or MACRO=(4 * 2000).
2020-11-06 17:25:22 +00:00
Rajkumar Kanagaraj 8016a53400 CMake: replace usage of the mbed_add_cmake_directory_if_labels() function (#13754)
Directories that start with special prefixes (TARGET_, FEATURE_, COMPONENT_)  are added to the build based on Mbed target configuration from targets.json instead of calling utility function mbed_add_cmake_directory_if_labels().
2020-11-06 17:25:21 +00:00
Hugues Kamba fa98689639 CMake: Componentize Mbed OS into multiple CMake targets (#13732)
Aside from the core mbed-os CMake target, a number of targets have been created so they can optionally be included by application executables that require them using `target_link_libraries()`.

Co-authored-by: Martin Kojtal <martin.kojtal@arm.com>
Co-authored-by: Rajkumar Kanagaraj <rajkumar.kanagaraj@arm.com>
2020-11-06 17:25:21 +00:00
Rajkumar Kanagaraj d84baa8fa1 CMake: Add a function to generate executable artifacts with memap (#13695)
- Add linker option to generate map file for GCC_ARM and ARM toolchain
- Add mbed_generate_map_file function to call memap.py (parse the map
file).
- Add mbed_generate_executable function to generate executable artifacts with a memory map table
2020-11-06 17:25:21 +00:00
Hugues Kamba 3b8aba1dce CMake: Add support for printf lib selection 2020-11-06 17:25:21 +00:00
Hugues Kamba 18345795cd CMake: Add support for C lib selection
Configure the selected toolchain for the selected C library
2020-11-06 17:25:21 +00:00
Hugues Kamba cac1b25465 CMake: Move modules under tools subdirectory 2020-11-06 17:25:21 +00:00
Hugues Kamba 37dd6d6064 CMake: Fix ARM toolchain configuration
mbed_generate_gcc_options_for_linker is to
be called only when GCC_ARM is selected.
2020-11-06 17:25:21 +00:00
Martin Kojtal 47f61485b8 CMake: Fix GCC_ARM pre-linking stage (#13575)
Make it generic for all targets. It was previously hardcoded for K64F
2020-11-06 17:25:20 +00:00
Martin Kojtal 9d1ae521e8 CMake: 3.18.2 minimum version set
There are fixes in the latest version we need for ARMClang.
2020-11-06 17:25:20 +00:00
Martin Kojtal 8aa4a85b35 CMake: use CMAKE_TOOLCHAIN_FILE
We should define CMAKE_TOOLCHAIN_FILE (as we are providing Mbed OS toolchain file). This fixes
also the issue we had with Unix makefiles where application would be without response files.

For more details, see https://gitlab.kitware.com/cmake/cmake/-/issues/21104

As the Mbed OS toolchain file is included by CMake, we need to have enabling language in the main CMake (can be executed
only once).
2020-11-06 17:25:20 +00:00
Hugues Kamba 7343ad6c02 CMake: Use `mbed_` prefix for CMake functions 2020-11-06 17:25:19 +00:00
Hugues Kamba 933b1db1be CMake: Set language std per target using properties 2020-11-06 17:25:19 +00:00
Hugues Kamba dde395c82f CMake: Do not hard code target in build profile CMake module
Provide a function in each build profile module to set the toolchain
options. All the functions have the same interface therefore the
CMake source file including the module always calls the same
function regardless of which build profile module is actually
included.
When the `mbed-os` target is broken up into multiple libraries,
a library other than `mbed-os` might need to set the toolchain
options. This will be possible by simply including the module
and calling the function with the target and toolchain for which
to set the options.
2020-11-06 17:25:19 +00:00
Hugues Kamba cb9960cb08 CMake: Do not hard code target in toolchain CMake module
Provide a function in each toolchain module to set the toolchain
specific options. All the functions have the same interface
therefore the CMake source file including the module always calls
the same function regardless of which toolchain module is actually
included.
When the `mbed-os` target is broken up into multiple libraries, a
library other than `mbed-os` might need to set the toolchain options.
This will be possible by simply including the module and calling the
function with the target for which to set the options.
2020-11-06 17:25:19 +00:00
Hugues Kamba 400211c490 CMake: Do not hard code target in CPU core CMake module
Provide a function in each CPU core module to set toolchain options.
All the functions have the same interface therefore the CMake source
file including the module always calls the same function regardless
of which cpu core module is actually included.
When the `mbed-os` target is broken up into multiple libraries, a
library other than `mbed-os` might need to set the toolchain options.
This will be possible by simply including the module and calling the
function with the target and toolchain for which to set the options.
2020-11-06 17:25:19 +00:00
Hugues Kamba de3462dabb CMake: Remove default build type selection from top level source file 2020-11-06 17:25:19 +00:00
Hugues Kamba c1fa350204 CMake: Minor formatting of top level CMakeLists.txt source file 2020-11-06 17:25:18 +00:00
Hugues Kamba 100be3d14b CMake: Fix ARM toolchain compilation
Ensure the MCU core CMake module is added before the toolchain
CMake module as the latter requires CMAKE_SYSTEM_PROCESSOR
to be set when configuring the ARM toolchain.
2020-11-06 17:25:18 +00:00
Hugues Kamba ef11e06cfb CMake: Remove add_executable
Instead provide functions to set the pre and post link commands.
2020-11-06 17:25:17 +00:00
Hugues Kamba c05170fbc8 CMake: Remove app.cmake module
This module was doing things that mbed-os and the application were supposed to do.
Moved the statements form the module to `mbed-os/CMakeLists.txt` and to
`<APPLICATION_ROOT>/CMakeLists.txt` .
Mbed OS also ensures the executable produced uses whatever name the application has set.
2020-11-06 17:25:17 +00:00
Robert Walton 0e1770daf5 Remove gen_config interface library target 2020-11-06 17:25:17 +00:00
Hugues Kamba 4b13332d59 CMake: Issue a fatal error if a lower version of CMake is used 2020-11-06 17:25:17 +00:00
Hugues Kamba 2d1508d9d0 CMake: Ensure targets creation before usage in `target_` functions
Move target creation statements before include statements. The targets
must be created before they can be used in `target_` functions.
2020-11-06 17:25:17 +00:00
Hugues Kamba e172eb33c9 CMake: Use modern CMake techniques to set toolchain options
Use target_compile_options(), target_compile_definitions(),
and target_link_options() to set toolchain options.
2020-11-06 17:25:17 +00:00
Martin Kojtal 08eb1e3f94 CMake: fix missing copyright 2020-11-06 17:25:16 +00:00
Martin Kojtal e2f38abe6f CMake env: remove components, needs design first 2020-11-06 17:25:16 +00:00
Hugues Kamba 6dc5f5a582 CMake: Add CMake scripts 2020-11-06 17:25:14 +00:00