Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add cmake doc #607

Merged
merged 11 commits into from
Jun 4, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions doc/cmake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 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])https://hsf-training.github.io/hsf-training-cmake-webpage/). PODIO follows the same conventions used therein.
tmadlener marked this conversation as resolved.
Show resolved Hide resolved

## Generate the C++ code
After a proper `find_package(PODIO)`, the C++ code of the new data model `NewDM` can be created and compiled via
hegner marked this conversation as resolved.
Show resolved Hide resolved

```
hegner marked this conversation as resolved.
Show resolved Hide resolved
# generate the c++ code from the yaml definition
PODIO_GENERATE_DATAMODEL(newdm newdm.yaml headers sources IO_BACKEND_HANDLERS)
hegner marked this conversation as resolved.
Show resolved Hide resolved

# compile the core data model shared library (no I/O)
PODIO_ADD_DATAMODEL_CORE_LIB(newdm "${headers}" "${sources}")
```

However, this does not create any I/O components yet. For this, 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:
hegner marked this conversation as resolved.
Show resolved Hide resolved

```
# 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
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(edm4hep "${headers}" "${sources}")
hegner marked this conversation as resolved.
Show resolved Hide resolved
```

For a more detailed example, please have a look at [EDM4hep](https://github.com/key4hep/EDM4hep/blob/main/edm4hep/CMakeLists.txt)
Loading