ecmwf / ecbuild

A CMake-based build system, consisting of a collection of CMake macros and functions that ease the managing of software build systems
https://ecbuild.readthedocs.io
Apache License 2.0
26 stars 25 forks source link

Possible bug with ecbuild and nested projects #25

Closed mathomp4 closed 4 years ago

mathomp4 commented 4 years ago

Another (possible?) bug we are seeing in our use of ecbuild. Namely, we want to nest ecbuild projects and we were seeing an issue. I'll attach a reproducer (ecbuild-reproducer.tar.gz) that shows the issue.

When you build the reproducer with the develop ecbuild, the resulting .cmake files look like:

install-with-develop/lib/cmake/
├── child_project
│   ├── child_project-targets-relwithdebinfo.cmake
│   ├── child_project-targets.cmake
│   ├── parent_project-config-version.cmake
│   └── parent_project-config.cmake
└── parent_project
    ├── parent_project-config-version.cmake
    ├── parent_project-config.cmake
    ├── parent_project-targets-relwithdebinfo.cmake
    └── parent_project-targets.cmake

As you can see, the child project has config files named parent. We have a fix such that when you install you get:

❯ tree install-with-patch/lib/cmake
install-with-patch/lib/cmake
├── child_project
│   ├── child_project-config-version.cmake
│   ├── child_project-config.cmake
│   ├── child_project-targets-relwithdebinfo.cmake
│   └── child_project-targets.cmake
└── parent_project
    ├── parent_project-config-version.cmake
    ├── parent_project-config.cmake
    ├── parent_project-targets-relwithdebinfo.cmake
    └── parent_project-targets.cmake

Here is our reproducer: ecbuild-reproducer.tar.gz

If you cmake .. and make install you should be able to verify. I'm also attaching a little "super" project that echoes why we need the fix: super.tar.gz

oiffrig commented 4 years ago

Thanks! The issue comes from the fact that ecbuild_system in included only in the parent project, which is fine as long as you do not intend to use the child project on its own.

Commit 5cb8c70 fixes the issue.