Building a new data model library with CMake
PODIO exposes multiple CMake macros to enable the building of data model libraries. For a package developer tutorial on CMake, please have a look here. PODIO follows the same conventions used therein.
Exported CMake functions and macros
The file cmake/podioMacros.cmake provides the following functions for external use:
PODIO_GENERATE_DATAMODEL- generate the data model from provided yaml filePODIO_ADD_DATAMODEL_CORE_LIB- compile the generated data modelPODIO_ADD_ROOT_IO_DICT- configure ROOT I/O backend and interface to PythonPODIO_ADD_SIO_IO_BLOCKS- configure SIO backend
Their exact parameters and functionality are documented in the file mentioned above. Below a few examples.
A simple example
After a proper find_package(podio REQUIRED), the C++ code of the new data model newdm can be created and compiled via
# generate the c++ code from the yaml definition
PODIO_GENERATE_DATAMODEL(newdm newdm.yaml headers sources)
# compile the core data model shared library (no I/O)
PODIO_ADD_DATAMODEL_CORE_LIB(newdm "${headers}" "${sources}")
# generate and compile the ROOT I/O dictionary for the default I/O system
PODIO_ADD_ROOT_IO_DICT(newdmDict newmdm "${headers}" src/selection.xml)
For an explicit choice of I/O backends one needs to add the IO_BACKEND_HANDLERS parameter and then generate and compile the corresponding backends, like shown below for the ROOT and SIO backends:
# generate the c++ code from the yaml definition
PODIO_GENERATE_DATAMODEL(newdm newdm.yaml headers sources IO_BACKEND_HANDLERS "ROOT;SIO")
# compile the core data model shared library (no I/O)
PODIO_ADD_DATAMODEL_CORE_LIB(newdm "${headers}" "${sources}")
# generate and compile the ROOT I/O dictionary for the default I/O system
PODIO_ADD_ROOT_IO_DICT(newdmDict newmdm "${headers}" src/selection.xml)
# compile the SIOBlocks shared library for the SIO backend
PODIO_ADD_SIO_IO_BLOCKS(newdm "${headers}" "${sources}")
For a complete example, please have a look at EDM4hep