Best practices for CMake with nested libraries

asked 2022-03-04 03:56:11 -0500

morten gravatar image

I have, at least what I think is, a slightly unique setup currently with some c++ code, and I'm curious if there exists some information in the ros world on what the best practice would be for structuring and compiling.

I have a node which makes usage of a library I've developed, the library itself is just c++ and contains some minimal ros elements like functions which can accept ros2 interfaces as inputs. The library is not defining a node, and it will be convenient for me to reuse this library in other, future packages as well.

Is there a best practice for how to structure this? Both in terms of the CMake file but also the folder structure.

My current structure is

  • pkg1/
    • include/pk1/
      • node.hpp
      • lib1.hpp
      • lib2.hpp
    • src/
      • node.cpp
    • CMakeLists.txt
edit retag flag offensive close merge delete