agri-gaia/seerep

Fix CMake find_package configuration for SEEREP_Core_FB

Opened this issue · 2 comments

A suitable quote that I found while figuring out (yet) another CMake Error:

CMake is anarchy

The seerep_core_fb package is a pure CMake package, no catkin involved. A ...Config.cmake.in file is used to define its dependencies. This file is passed to CMake to generate the required Config.cmake, which is needed by find_package

The problem is that the cmake.in file has not been updated and still has Protocol Buffer dependencies?!

find_package(Protobuf REQUIRED)
list(APPEND SeerepCoreFb_INCLUDE_DIRS ${Protobuf_INCLUDE_DIR})
list(APPEND SeerepCoreFb_LIBRARIES ${Protobuf_LIBRARY})
find_package(HDF5 REQUIRED)
list(APPEND SeerepCoreFb_INCLUDE_DIRS ${HDF5_INCLUDE_DIRS})
list(APPEND SeerepCoreFb_LIBRARIES ${HDF5_LIBRARIES})
find_package(HighFive REQUIRED)
list(APPEND SeerepCoreFb_INCLUDE_DIRS ${HighFive_INCLUDE_DIRS})
list(APPEND SeerepCoreFb_LIBRARIES ${HighFive_LIBRARIES})
find_package(SeerepMsgs REQUIRED)
list(APPEND SeerepCoreFb_INCLUDE_DIRS ${SeerepMsgs_INCLUDE_DIRS})
list(APPEND SeerepCoreFb_LIBRARIES ${SeerepMsgs_LIBRARIES})
find_package(SeerepHdf5Pb REQUIRED)
list(APPEND SeerepCoreFb_INCLUDE_DIRS ${SeerepHdf5Pb_INCLUDE_DIRS})
list(APPEND SeerepCoreFb_LIBRARIES ${SeerepHdf5Pb_LIBRARIES})

Now if another package want's to use seerep_core_fb and the PB packages have not been build before, an error like this will be thrown

CMake Error at /seerep/devel/lib/cmake/seerepcorefb/SeerepCoreFbConfig.cmake:51 (find_package):
  By not providing "FindSeerepHdf5Pb.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "SeerepHdf5Pb", but CMake did not find one.

  Could not find a package configuration file provided by "SeerepHdf5Pb" with
  any of the following names:

    SeerepHdf5PbConfig.cmake
    seerephdf5pb-config.cmake

Of course, this doesn't happen if you run catkin build to build all packages.

Meta Issue #141

This issue probably also applies to other packages