cmake(enhance):enhance NuttX cmake target_dependencies and link_library modules #14907
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
After #14747, we have a preliminary extensions design : )
I have two enhance ideas here:
1.link_library
In the Nuttx CMake build system, we cannot call target_link_library
Why?
this is because we need to consider different build MODES,
different static libs need to be connected to the
kernel
oruser
blob,which results in the link target of nuttx to be manually controlled.
Refer to the implementation of add_library
This creates a problem that goes against the intuition of using CMake.
target_link_library
cannot be called, otherwise the problem of multi defines will occur during linking.ref: #14757 and apache/nuttx-apps#2846
So I enhance
target_link_library
tonuttx_link_library
,It only inherits the public properties of the linked one without actually connecting it.
2.add_dependencies
The NuttX CMake build system executes sequentially when traversing all subdirectories.
This will also cause a problem, that is, when using
add_dependencies(targetA targetB)
, targetB may not have been traversed yet.So I enhanced
nuttx_add_dependencies
, which only records dependencies and mappings when called,and actually executes dependencies after all targets are traversed.
3.other shortcut calls
set scope is all the APPS include search path, compile_options, definitions.
Impact
Enhanced functions, fully compatible with existing cases
Testing
test build with:
build pass