Commit Graph

111 Commits (feature-cmake-object-libraries)

Author SHA1 Message Date
Martin Kojtal f0b5d0f7eb CMake: add comment about OBJECT limitation and our source tree deps 2021-03-15 10:05:58 +00:00
Martin Kojtal d56af904d7 CMake: rename -obj to -objects libraries
Easier to understand
2021-03-15 10:05:58 +00:00
Martin Kojtal bff287680e CMake: add comments to internal mbed-os libraries 2021-03-15 10:05:56 +00:00
Martin Kojtal 92f3529e2f CMake: fix baremetal, core-obj links to core and target 2021-03-15 10:05:56 +00:00
Martin Kojtal 86f1ad74cc CMake: core should expose also compile defs from target 2021-03-15 10:05:55 +00:00
Martin Kojtal 79fac4f62e CMake: expose targets includes to mbed-core
We do not want an app to link core and also targets. As both actually create one core component.
Therefore expose include dirs from targets to core.

mbed-events for instance should just link to mbed-core and it should get all it needs.
2021-03-15 10:05:55 +00:00
Martin Kojtal b0b242eba0 CMake: remove util function, link object libs regularly 2021-03-15 10:05:55 +00:00
Martin Kojtal 5e5da9be9a CMake: simplify internal object libraries
Link what we can link with CMake. We still need copy core sources to mbed-os-obj. And expose
also link options to app as linker flags are provided via them. Normally, we would link to
target library but as it's interface, we would copy the sources as well, this is not what we want.
2021-03-15 10:05:53 +00:00
Martin Kojtal ca1fa9f3c1 CMake: add comments for the magic we do around core/rtos libraries 2021-03-15 10:05:53 +00:00
Martin Kojtal 5dfedfca52 CMake readme: fix typos in the comment 2021-03-15 10:05:52 +00:00
Martin Kojtal 73471fa026 CMake: copy compile defs and link options to core from targets 2021-03-15 10:05:52 +00:00
Martin Kojtal 5236f5009f CMake: fix exposing target includes for mbed-os/baremetal 2021-03-15 10:05:51 +00:00
Martin Kojtal 15c5f79224 CMake: core exports target includes for other components to be available 2021-03-15 10:05:51 +00:00
Martin Kojtal 29dc6a72f4 CMake: fix baremetal build 2021-03-15 10:05:50 +00:00
Martin Kojtal 34cfda05bc CMake: use Jamies trick to copy core files and build with Mbed OS 2021-03-15 10:05:49 +00:00
Martin Kojtal c3e0534820 CMake cmsis: add only headers from targets, not everything 2021-03-15 10:05:49 +00:00
Martin Kojtal 3d66d0ff7d CMake Maxim: turn maxim targets to interface libs
Copy over what core and app needs. This still does not build though, target objects
are copied to multiple places.
2021-03-15 10:05:48 +00:00
Martin Kojtal d6041a00de 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.
2021-03-15 10:05:47 +00:00
Martin Kojtal ab0be209f0 CMake: provide util function to connect object with interface lib 2021-03-15 10:05:47 +00:00
Martin Kojtal 11cd2820b2 CMake: hit object library cyclic deps error 2021-03-15 10:05:47 +00:00
Martin Kojtal 3d36e28307 CMake: mbed target converted is cached variable 2021-03-15 10:05:46 +00:00
Martin Kojtal f0d67431ff CMake: fix deps on other libraries 2021-03-15 10:05:45 +00:00
Martin Kojtal 494d0c0711 CMake: turn mbed-core into interface + obj libraries 2021-03-15 10:05:43 +00:00
Lingkai Dong ad27a3ec69 CMake: pass application name to post-build hook
Pass the exact name to the post-build hook, when an application's
or test's `CMakeLists.txt` calls `mbed_set_post_build()`. The
interface is CMake's built-in mechanism:
* `set_target_properties()` to set a property, e.g. application name
* `$<TARGET_PROPERTY:target,property>` to query a property at run time
2021-03-04 09:41:48 +00:00
Lingkai Dong 3579bb65da Force regenerate application binaries on rebuild
If a target has a post binary hook, we should force regenerate
the application binaries every time so that the hook is run on a
raw binary rather than a previous build that already went through
the post-build process once.
2021-03-04 09:41:43 +00:00
Ladislas de Toldi fd7ea7305f
Configure memory map per target to allow multiple add_executable 2021-02-27 13:16:03 +01:00
Martin Kojtal eceaea54fd
Merge pull request #14299 from hugueskamba/hk_cmake_refactor_mapfile_generation
CMake: Refactor mapfile generation
2021-02-25 15:08:55 +00:00
Martin Kojtal 7da6100ff6
Merge pull request #14304 from hugueskamba/hk_cmake_remove_app_target_reference
CMake: Refactor post-build hook to remove APP_TARGET references
2021-02-25 10:41:44 +00:00
Hugues Kamba ed09a5cc95 CMake: Refactor mapfile generation
The refactoring was necessary to remove a function call
(mbed_configure_app_target()) from application's CMakeLists.txt.
2021-02-23 11:39:00 +00:00
Hugues Kamba 0eae4f6c3f CMake: Refactor post-build hook to remove APP_TARGET references
There should not be a reference to APP_TARGET in Mbed OS as end-users
may decide to use a different name for the CMake variable to store their
application name.
2021-02-19 11:52:57 +00:00
Martin Kojtal 546cdafbd9
CMake: remove debug print 2021-02-17 16:50:13 +00:00
Martin Kojtal 8bdc626ba7
Merge pull request #14286 from 0xc0170/cmake-fix-remove-target-workaround
CMake: remove workaround for targets prior refactor
2021-02-16 14:28:26 +00:00
Martin Kojtal 3894d73680
Merge pull request #14289 from hugueskamba/hk_cmake_refactor_cypress
CMake: Refactor Cypress targets
2021-02-16 13:43:35 +00:00
Hugues Kamba 68b6e6ff96 Fix post build mechanism with unique CMake custom targets
The CMake custom target must be unique to avoid more than one
Mbed target adding the same. Only the CMake custom command added for the
Mbed target being built is run as the custom CMake target now includes
the Mbed target name.
2021-02-15 17:39:27 +00:00
Martin Kojtal 9d70cb2a56 CMake: remove workaround for targets prior refactor
As we refactored all targets, we can remove this workaround from the tree.
2021-02-15 14:11:09 +00:00
Robert Walton 0c7bfe93e3 CMake: Generate response file before adding mbed-targets
We need to generate a "response file" to pass to the C preprocessor
when we preprocess the linker script, because of path length limitations
on Windows. We set the response file and bind the path to a global
property. The MBED_TARGET being built queries this global property when
it sets the linker script.

We must set this global property before the targets subdirectory is
added to the project. This is required because the MBED_TARGET depends
on the response file. If the path to the response file is not defined
when the target requests it the config definitions will not be passed
to CPP.
2021-02-15 11:12:18 +00:00
Martin Kojtal ba1e7b53d0
Merge pull request #14272 from ladislas/ladislas/feature/cmake-current-binary-dir
Change CMAKE_BINARY_DIR to CMAKE_CURRENT_BINARY_DIR
2021-02-14 19:23:46 +00:00
Ladislas de Toldi 5a879c6a4e
Change CMAKE_BINARY_DIR to CMAKE_CURRENT_BINARY_DIR 2021-02-11 22:49:07 +01:00
Hugues Kamba deeaa7970f CMake: Add post build operation support
A CMake custom target, mbed-post-build, is added as a dependency of the
application CMake target if a Mbed target adds a CMake custom target
named mbed-post-build-bin. mbed-post-build-bin is added as a dependency
of mbed-post-build. mbed-post-build-bin depends on the application binary.
This is done so a CMake custom command that executes post-build can be added.

The Python scripts that implement the operations have been modified to add
CLI entry points so they can be called from CMake. Dependency on the old
tool has been removed on those scripts by passing them exactly what they
require instead of passing old tool Python objects. A consequence of that
was to slightly amend how the old tool calls some of those Python modules.

Support has only been added for Mbed targets that currently have a requirement
for post build operations. This includes: LPC1114, LPC1768, ARCH_PRO, LPC54114,
LPC546XX, FF_LPC546XX, CY8CKIT064B0S2_4343W, CYTFM_064B0S2_4343W, CYSBSYSKIT_01

The following targets are not supported as TFM support is not yet included:
ARM_MUSCA_B1, ARM_MUSCA_B1_NS, ARM_MUSCA_S1, ARM_MUSCA_S1_NS.
2021-02-11 17:04:41 +00:00
Martin Kojtal 33c06fb346
Merge pull request #14265 from 0xc0170/cmake-fix-app-target
CMake: remove need for APP_TARGET
2021-02-11 11:49:16 +00:00
Martin Kojtal 207dcbb88b CMake: move Gcc Arm memmap to configure app
This allows us to keep all in one place and fix (removing this function later)
2021-02-10 19:37:42 +00:00
Martin Kojtal b9990089eb
CMake: fix wording in naming
Co-authored-by: Hugues Kamba <41612201+hugueskamba@users.noreply.github.com>
2021-02-10 12:15:48 +00:00
Martin Kojtal d22772342c CMake: linker script preprocessing moved to mbed_configure_app_target
This fixes the problem for an app/test to define APP_TARGET as requirements. This is not a proper fix
but rather a workaround for broken apps/tests currently. We will address this separately via new
pull request.
2021-02-10 11:32:08 +00:00
Martin Kojtal b3344390dd CMake: move language standard to mbed-core
We set language standard via mbed-core and app inherits it if links to it.
This is breaking change for application, please remove the function call from an
application and it should build without errors.
2021-02-10 11:31:50 +00:00
Martin Kojtal 4536a5efe5
Update CMakeLists.txt
Co-authored-by: Hugues Kamba <41612201+hugueskamba@users.noreply.github.com>
2021-02-10 08:46:25 +00:00
Martin Kojtal e88e1149e2 CMake: fix the comment for naming targets 2021-02-09 17:12:23 +00:00
Martin Kojtal 39ab9c8b99 CMake: add naming convention for mbed targets
Using lowercase with dashes for targets with mbed- prefix
2021-02-09 15:23:17 +00:00
Martin Kojtal dd33463518
Merge pull request #14205 from multiplemonomials/master
CMake: better detection of memap dependencies
2021-02-05 10:13:18 +00:00
Robert Walton 0e491cc0cf cmake: Refactor mbed_set_mbed_target_linker_script
Move the mbed_set_mbed_target_linker_script function into its own file
and make it set the linkerscript on the target passed in, rather than
setting the linkerscript on the top level mbed-core target. We use
CMake's automatic forwarding of usage requirements to forward the linker
script to the top level target.

This commit also adds a condition to check whether the MBED_TARGET is a
CMake buildsystem target. If it is we will just link to it in the
idiomatic CMake way, if it's not then we use the 'old' mechanism of
setting the linkerscript for the mbed-core target. This check will be
useful when we refactor MBED_TARGETS to be CMake buildsystem targets as
it will allow us to do the refactoring incrementally.
2021-02-04 15:26:33 +00:00
Robert Walton 8f47212085 cmake: Remove whitespace from mbed-os/CMakeLists.txt 2021-02-04 15:23:49 +00:00