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 more advanced cmake macro features to documentation #685

Merged
merged 3 commits into from
Sep 26, 2024

Conversation

SaxenaAnushka102
Copy link
Contributor

@SaxenaAnushka102 SaxenaAnushka102 commented Sep 21, 2024

BEGINRELEASENOTES

  • Add advanced CMake usage for PODIO_GENERATE_DATAMODEL to docs

ENDRELEASENOTES

Fixes #613

Add advance CMake usage for `PODIO_GENERATE_DATAMODEL`
doc/cmake.md Outdated

```cmake
# Generate the C++ code from the YAML definition with an upstream EDM, dependencies, version, output folder, and I/O handlers
PODIO_GENERATE_DATAMODEL(newdm newdm.yaml headers sources
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pre-commit complains about the trailing whitespace here

Suggested change
PODIO_GENERATE_DATAMODEL(newdm newdm.yaml headers sources
PODIO_GENERATE_DATAMODEL(newdm newdm.yaml headers sources

Copy link
Collaborator

@tmadlener tmadlener left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for this. I have a few suggestions to further improve on this.

doc/cmake.md Outdated
## More advanced data model generation
PODIO provides additional options within the `PODIO_GENERATE_DATAMODEL` macro that allow developers to fine-tune how data models are generated and compiled:

1. `UPSTREAM_EDM` - use an existing EDM an upstream dependency. This is useful when your data model extends or builds on top of another one, such as using EDM4hep in [EDM4eic](https://github.com/eic/EDM4eic/blob/7a627488cde0bc4e1863d3fd6bd3396fd30c7296/CMakeLists.txt#L44-L48).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. `UPSTREAM_EDM` - use an existing EDM an upstream dependency. This is useful when your data model extends or builds on top of another one, such as using EDM4hep in [EDM4eic](https://github.com/eic/EDM4eic/blob/7a627488cde0bc4e1863d3fd6bd3396fd30c7296/CMakeLists.txt#L44-L48).
1. `UPSTREAM_EDM` - use an existing EDM as an upstream dependency. This is useful when your data model extends or builds on top of another one, such as using EDM4hep in [EDM4eic](https://github.com/eic/EDM4eic/blob/7a627488cde0bc4e1863d3fd6bd3396fd30c7296/CMakeLists.txt#L44-L48).

doc/cmake.md Outdated
PODIO provides additional options within the `PODIO_GENERATE_DATAMODEL` macro that allow developers to fine-tune how data models are generated and compiled:

1. `UPSTREAM_EDM` - use an existing EDM an upstream dependency. This is useful when your data model extends or builds on top of another one, such as using EDM4hep in [EDM4eic](https://github.com/eic/EDM4eic/blob/7a627488cde0bc4e1863d3fd6bd3396fd30c7296/CMakeLists.txt#L44-L48).
2. `DEPENDS` - tells CMake that some files used to build the data model are not generated during the current build but are still required for compilation, like in [EDM4hep](https://github.com/key4hep/EDM4hep/blob/ac83112d66f7aa3b9d4eb5859c19b987feab3ce5/edm4hep/CMakeLists.txt#L6-L8)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
2. `DEPENDS` - tells CMake that some files used to build the data model are not generated during the current build but are still required for compilation, like in [EDM4hep](https://github.com/key4hep/EDM4hep/blob/ac83112d66f7aa3b9d4eb5859c19b987feab3ce5/edm4hep/CMakeLists.txt#L6-L8)
2. `DEPENDS` - tells CMake that some files used to build the data model are not generated during the current build but are still required for compilation and should trigger a rebuild in case of changes, like in [EDM4hep](https://github.com/key4hep/EDM4hep/blob/ac83112d66f7aa3b9d4eb5859c19b987feab3ce5/edm4hep/CMakeLists.txt#L6-L8)

doc/cmake.md Outdated

1. `UPSTREAM_EDM` - use an existing EDM an upstream dependency. This is useful when your data model extends or builds on top of another one, such as using EDM4hep in [EDM4eic](https://github.com/eic/EDM4eic/blob/7a627488cde0bc4e1863d3fd6bd3396fd30c7296/CMakeLists.txt#L44-L48).
2. `DEPENDS` - tells CMake that some files used to build the data model are not generated during the current build but are still required for compilation, like in [EDM4hep](https://github.com/key4hep/EDM4hep/blob/ac83112d66f7aa3b9d4eb5859c19b987feab3ce5/edm4hep/CMakeLists.txt#L6-L8)
3. `VERSION` - specifies how to inject the version of the datamodel (it is separate from the schema version).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
3. `VERSION` - specifies how to inject the version of the datamodel (it is separate from the schema version).
3. `VERSION` - specifies the version of the datamodel (it is separate from the schema version). This will be injected into the metadata that is stored in files.

doc/cmake.md Outdated
# Generate the C++ code from the YAML definition with an upstream EDM, dependencies, version, output folder, and I/O handlers
PODIO_GENERATE_DATAMODEL(newdm newdm.yaml headers sources
    UPSTREAM_EDM "EDM4hep:edm4hep"
    DEPENDS "external_file.yaml;another_dependency.yaml"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
    DEPENDS "external_file.yaml;another_dependency.yaml"
    DEPENDS "extra_header.h;more_extras.h"

The main purpose here is to pass in additional c++ files which should become part of the compiled datamodel library.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, thanks for clarifying!

doc/cmake.md Outdated
Comment on lines 67 to 75

# 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 newdm "${headers}" src/selection.xml)

# Compile the SIOBlocks shared library for the SIO backend
PODIO_ADD_SIO_IO_BLOCKS(newdm "${headers}" "${sources}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# 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 newdm "${headers}" src/selection.xml)
# Compile the SIOBlocks shared library for the SIO backend
PODIO_ADD_SIO_IO_BLOCKS(newdm "${headers}" "${sources}")

Since these are unchanged wrt the basic examples above and these don't have too many customization points, we can simply remove them here to reduce the "noise" a bit.

@SaxenaAnushka102
Copy link
Contributor Author

Hi @tmadlener @m-fila, I noticed two checks are failing: pre-commit and sanitizers (gcc13, Address). I've reviewed the logs, but I'm unsure how to resolve the pylint & missing file issues. Will retrying the build solve this? Could you please provide some guidance on what might be going wrong here?

@tmadlener
Copy link
Collaborator

The failing CI is unrelated to the changes you made. The sanitizer one wasn't able to download a test file. I am not yet sure what is wrong with pre-commit, but it has been failing for other PRs as well. I am investigating at the moment.

@tmadlener
Copy link
Collaborator

If you rebase this onto the latest master branch, CI should fix itself

@tmadlener tmadlener changed the title Update cmake.md Add more advanced cmake macro features to documentation Sep 26, 2024
@tmadlener tmadlener merged commit 2d3b4fe into AIDASoft:master Sep 26, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document more advanced cmake usage
3 participants