diff options
| author | Jim Mussared <jim.mussared@gmail.com> | 2023-05-12 17:03:14 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2023-06-01 16:21:37 +1000 |
| commit | 5e0452125146f3afed89c09f5813790156d24471 (patch) | |
| tree | 7c8226caf407554a8d5fc7c5a78ac056c9c82e71 /examples/usercmodule/subpackage/micropython.cmake | |
| parent | 6a8114eee8ff486d812b4efc5a94880b565640f3 (diff) | |
examples/usercmodule: Add a sub-package example.
This demonstrates how to add a sub-package in a user c module, as well
as how to define the necessary qstrs and enable the feature in the build.
This is used by the unix coverage build to test this feature.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'examples/usercmodule/subpackage/micropython.cmake')
| -rw-r--r-- | examples/usercmodule/subpackage/micropython.cmake | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/examples/usercmodule/subpackage/micropython.cmake b/examples/usercmodule/subpackage/micropython.cmake new file mode 100644 index 000000000..a51e7a806 --- /dev/null +++ b/examples/usercmodule/subpackage/micropython.cmake @@ -0,0 +1,19 @@ +# Create an INTERFACE library for our C module. +add_library(usermod_subpackage_example INTERFACE) + +# Add our source files to the lib +target_sources(usermod_subpackage_example INTERFACE + ${CMAKE_CURRENT_LIST_DIR}/examplemodule.c +) + +# Add the current directory as an include directory. +target_include_directories(usermod_subpackage_example INTERFACE + ${CMAKE_CURRENT_LIST_DIR} +) + +target_compile_definitions(usermod_subpackage_example INTERFACE + MICROPY_MODULE_BUILTIN_SUBPACKAGES=1 +) + +# Link our INTERFACE library to the usermod target. +target_link_libraries(usermod INTERFACE usermod_subpackage_example) |
