From cc497d4c6a7bbf491fbc57b9447632bddff8d566 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Tue, 23 Feb 2021 23:06:04 +0000 Subject: [PATCH] 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 --- .../usercmodule/cexample/micropython.cmake | 21 ++++++++++++++++++ .../usercmodule/cppexample/micropython.cmake | 22 +++++++++++++++++++ examples/usercmodule/micropython.cmake | 11 ++++++++++ 3 files changed, 54 insertions(+) create mode 100644 examples/usercmodule/cexample/micropython.cmake create mode 100644 examples/usercmodule/cppexample/micropython.cmake create mode 100644 examples/usercmodule/micropython.cmake diff --git a/examples/usercmodule/cexample/micropython.cmake b/examples/usercmodule/cexample/micropython.cmake new file mode 100644 index 0000000000..371a3eefa4 --- /dev/null +++ b/examples/usercmodule/cexample/micropython.cmake @@ -0,0 +1,21 @@ +# Create an INTERFACE library for our C module. +add_library(usermod_cexample INTERFACE) + +# Add our source files to the lib +target_sources(usermod_cexample INTERFACE + ${CMAKE_CURRENT_LIST_DIR}/examplemodule.c +) + +# Add the current directory as an include directory. +target_include_directories(usermod_cexample INTERFACE + ${CMAKE_CURRENT_LIST_DIR} +) + +# Enable the module automatically by adding the relevant compile definitions. +target_compile_definitions(usermod_cexample INTERFACE + MODULE_CEXAMPLE_ENABLED=1 +) + +# Link our INTERFACE library to the usermod target. +target_link_libraries(usermod INTERFACE usermod_cexample) + 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) + diff --git a/examples/usercmodule/micropython.cmake b/examples/usercmodule/micropython.cmake new file mode 100644 index 0000000000..ad88d77806 --- /dev/null +++ b/examples/usercmodule/micropython.cmake @@ -0,0 +1,11 @@ +# This top-level micropython.cmake is responsible for listing +# the individual modules we want to include. +# Paths are absolute, and ${CMAKE_CURRENT_LIST_DIR} can be +# used to prefix subdirectories. + +# Add the C example. +include(${CMAKE_CURRENT_LIST_DIR}/cexample/micropython.cmake) + +# Add the CPP example. +include(${CMAKE_CURRENT_LIST_DIR}/cppexample/micropython.cmake) +