summaryrefslogtreecommitdiffstatshomepage
path: root/examples/usercmodule/cppexample
diff options
context:
space:
mode:
authorPhil Howard <phil@gadgetoid.com>2021-02-23 23:06:04 +0000
committerDamien George <damien@micropython.org>2021-03-31 00:27:46 +1100
commitcc497d4c6a7bbf491fbc57b9447632bddff8d566 (patch)
treef6f6a57be56902ed798fc1128365b816dc49358e /examples/usercmodule/cppexample
parent0cf12dd59c9ddddbd602d4267410033cb5a9d265 (diff)
downloadmicropython-cc497d4c6a7bbf491fbc57b9447632bddff8d566.tar.gz
micropython-cc497d4c6a7bbf491fbc57b9447632bddff8d566.zip
examples/usercmodule: Add micropython.cmake to the C and CPP examples.
examples/usercmodule/micropython.cmake: Root micropython.cmake file is responsible for including modules. examples/usercmodule/cexample/micropython.cmake: examples/usercmodule/cppexample/micropython.cmake: Module micropython.cmake files define the target and link it to usermod. Signed-off-by: Phil Howard <phil@pimoroni.com>
Diffstat (limited to 'examples/usercmodule/cppexample')
-rw-r--r--examples/usercmodule/cppexample/micropython.cmake22
1 files changed, 22 insertions, 0 deletions
diff --git a/examples/usercmodule/cppexample/micropython.cmake b/examples/usercmodule/cppexample/micropython.cmake
new file mode 100644
index 0000000000..43e8d887f5
--- /dev/null
+++ b/examples/usercmodule/cppexample/micropython.cmake
@@ -0,0 +1,22 @@
+# Create an INTERFACE library for our CPP module.
+add_library(usermod_cppexample INTERFACE)
+
+# Add our source files to the library.
+target_sources(usermod_cppexample INTERFACE
+ ${CMAKE_CURRENT_LIST_DIR}/example.cpp
+ ${CMAKE_CURRENT_LIST_DIR}/examplemodule.c
+)
+
+# Add the current directory as an include directory.
+target_include_directories(usermod_cppexample INTERFACE
+ ${CMAKE_CURRENT_LIST_DIR}
+)
+
+# Enable the module automatically by adding the relevant compile definitions.
+target_compile_definitions(usermod_cppexample INTERFACE
+ MODULE_CPPEXAMPLE_ENABLED=1
+)
+
+# Link our INTERFACE library to the usermod target.
+target_link_libraries(usermod INTERFACE usermod_cppexample)
+