Packaging & Integration
This page covers how to consume DataLayerGenerator as a Conan package and how to integrate the code generator into your own CMake project.
Installing the Package from Source
# From the repository root
conan create . --build=missing
This installs datalayer-generator/0.0.1 into your local Conan cache.
Conan Options
Option |
Default |
Description |
|---|---|---|
|
|
Require |
|
|
Propagate |
|
|
Require |
Example conanfile.txt for a consumer project:
[requires]
datalayer-generator/0.0.1
[options]
datalayer-generator/*:with_fmt=True
datalayer-generator/*:with_file_persistence=False
[generators]
CMakeDeps
CMakeToolchain
CMake Integration for Consumers
After running conan install the DataLayerGeneratorHelpers.cmake module is injected
automatically. Use find_package and the generate_datalayer() function:
cmake_minimum_required(VERSION 3.19)
project(MyApp LANGUAGES CXX)
find_package(DataLayerGenerator REQUIRED)
add_executable(my_app main.cpp)
target_link_libraries(my_app PRIVATE DataLayerGenerator::DataLayerGenerator)
# Run generator.py at build time from your own model directory
generate_datalayer(my_app
MODEL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/model
OUT_DIR ${CMAKE_CURRENT_BINARY_DIR}
MODULE_NAME my_python_module # optional, for pybind11
)
The generate_datalayer() function:
Finds the Python interpreter.
Adds an
add_custom_commandthat runsgenerator.pywhen model files change (stamp-file based — no unnecessary reruns).Adds
<out_dir>/generated/includeand<out_dir>/generatedto the target’s include path.
The DataLayerGenerator::DataLayerGenerator INTERFACE target:
Adds
src/include/(the framework headers) to the consumer’s include path.Requires C++20.
Propagates
USE_FMTand/orUSE_FILE_PERSISTENCEdefines when the corresponding Conan options are enabled.
Building the Documentation
The docs target requires Doxygen and Sphinx. Enable it by uncommenting
ADD_SUBDIRECTORY(docs) in the root CMakeLists.txt and install the Python dependencies:
pip install sphinx sphinx-rtd-theme breathe sphinx-copybutton
Then build:
cmake --build build --target Sphinx
The HTML output is written to <build>/docs/sphinx/.
Cross-Compilation (ARM Cortex-M4)
The project includes a GCC ARM Cortex-M4 toolchain in cmake/arm-cortex-gnu/. When
CMAKE_CROSSCOMPILING is set (e.g. via CMakePresets.json or a -DCMAKE_TOOLCHAIN_FILE):
The build switches to
embedded.cppas the entry point.The linker script
src/linkerscript/linkerScript.ldis applied..elf,.bin, and.hexartefacts are produced ininstall/.Tests are skipped.
Only
fmtis required by Conan (catch2andpybind11are excluded onarmv7).
</content> </invoke>