mrt_cmake_modules package from mrt_cmake_modules repomrt_cmake_modules |
|
Package Summary
Tags | No category tags. |
Version | 1.0.11 |
License | BSD |
Build type | CATKIN |
Use | RECOMMENDED |
Repository Summary
Checkout URI | https://github.com/KIT-MRT/mrt_cmake_modules.git |
VCS Type | git |
VCS Version | master |
Last Updated | 2024-09-20 |
Dev Status | MAINTAINED |
CI status | No Continuous Integration |
Released | RELEASED |
Tags | No category tags. |
Contributing |
Help Wanted (0)
Good First Issues (0) Pull Requests to Review (0) |
Package Description
Additional Links
Maintainers
- Kevin Rösch
- Fabian Poggenhans
Authors
- Fabian Poggenhans
- Johannes Beck
MRT CMake Modules (Massively Reduced Time writing CMake Modules(*))
Maintainer status: maintained
- Maintainer: Kevin Rösch, Fabian Poggenhans
- Author: Johannes Beck, Claudio Bandera, Fabian Poggenhans
- License: BSD, some files MIT
- Bug / feature tracker: https://gitlab.mrt.uni-karlsruhe.de/MRT/mrt_cmake_modules/issues
- Source: git https://gitlab.mrt.uni-karlsruhe.de/MRT/mrt_cmake_modules.git (branch: master)
Imagine you whould never have to write a CMakeLists.txt file again. Never forget to install everything, no need to update it whenever you add a file, not time lost for figuring out how to call and use find_package
for your dependencies, etc.
Well, this is exactly what mrt_cmake_modules
do for you! The only thing you have to do is:
- Keep your files in a fixed structure,
- keep library and executable code in separate packages and
- make sure the package.xml actually contains all the packages you depend on.
If you don’t want to agree to this, there are ways to get this done as well. This will require you to modify our template file a bit.
On the other hand, you get a lot of things for free:
- Resolution of your dependencies in CMake
- Automatic generation of Nodes/Nodelets
- Supports C++ and Python(2/3)
- Python bindings for pybind11/boost-python
- Automated unittest detection and execution (including ROS tests)
- Automated code coverage generation
- Support for sanitizers
- Support for running clang-tidy
- Automated install of your scripts/launchfiles/executables/libraries… to the correct location
- experimental support for ROS2 and Conan builds
) Actually MRT stands for *Institut für Mess- und Regelungstechnik, the institute that develops this package.
Building
mrt_cmake_modules
is kept as leightweight as possible. It just contains a few CMake (and python) scripts. Its only dependency is catkin
and lcov
(for code coverage).
Getting started
Interested? In order to get the CMake template file, you have to run a small script: rosrun mrt_cmake_modules generate_cmakelists.py <package_name> [--ros] [--exe]
.
This will create a CMakeLists.txt file ready to be used in your project. We distinguish four different types of packages (this the --ros
and --exe
flags):
-
Library package: They have no dependency to ros (except catkin). Their goal is to either build a
lib<package>.so
, contain only headers, contain a python module, contain python bindings. Or a mixture of these. And unittests, of course. - Ros library package (–ros): Similar to the above, but can also contain message, action or configuration files
- Executable package (–exe): Provides either a number of executables, scripts or python modules for these scripts. And unittests of course.
- Node/Nodelet package (–ros –exe): Provides a number of nodes or nodelets, python nodes and launchfiles. And rostests of course.
Package structure
The best way to understand how packages have to be layed out is to have a look at the tree of an example package, and what it implies on the build.
Libraries
Here is the structure of a package called example_package
. It works out of the box with a CMakeLists.txt created with generate_cmakelists.py example_package --ros
:
.
├── CMakeLists.txt # The generated CMakeLists
├── include # The headers of this package. Available in the whole package
│ └── example_package # It is a ROS convention to keep them within include/<package_name>
│ ├── a_header.hpp
│ └── internal # Headers here are only to be used within cpp files of this package
│ └── internal_header.hpp
├── msg
│ └── a_message.msg # Messages files that will be automatically generated (only available for --ros)
├── package.xml # You should know that. Should contain at least pybind11-dev for the bindings
├── python_api # Folder for python bindings. Every file here becoms a module
│ ├── python_bindings.cpp # Will be available as "import example_package.python_bindings"
│ └── more_python_bindings.cpp # Refer to the pybind11 doc for the content of this file
├── README.md # The readme
├── src # Every cpp file in this filder will become part of libexample_package.so
│ ├── examplefile.cpp
│ ├── onemorefile.cpp
│ └── example_package # Python modules have to go to src/<package_name>
│ ├── pythonmodule.py # Will be available as "import example_package.pythonmodule"
│ └── __init__.py
└── test # Contains the unittests. Will be executed when running the test or run_tests target
├── test_example_package.cpp # Every file here will be a separate unittest executable
└── test_pyapi.py # Every py file that matches the testMatch regular expression will be executed
# using nosetest. Executables are ignored. See https://nose.readthedocs.io/
Note that everything in this structure is optional and can be left away if you don’t need it (except for the CMakeLists.txt of course).
Executables, Nodes and Nodelets
Here is the structure of a package called example_package_ros_tool
.
It works out of the box with a CMakeLists.txt created with generate_cmakelists.py example_package_ros_tool --exe --ros
:
.
├── CMakeLists.txt
├── cfg
│ └── ConfigFile.cfg # Files to be passed to dynamic_reconfigure
├── launch # Contains launch files provided by this package
│ ├── some_node.launch
│ ├── some_nodelet.launch
│ ├── some_python_node.launch
│ └── params # Contains parameter files that will be installed
│ ├── some_parameters.yaml
│ └── some_python_parameters.yaml
├── nodelet_plugins.xml # Should reference the nodelet library at lib/lib<package_name>-<nodename>-nodelet
├── package.xml # The manifest. It should reference the nodelet_plugins.xml
├── README.md
├── scripts # Executable scripts that will be installed. These can be python nodes as well
│ ├── bias_python_node.py
│ └── bias_script.sh
├── src # Every folder in here will be a node/nodelet or both
│ ├── nodename # nodename is the name of the node/nodelet
│ │ ├── somefile.cpp # Files compiled into the node and the nodelet
│ │ ├── somefile.hpp
│ │ ├── some_node.cpp # files ending with _node will end up being compiled into the node executable
│ │ └── a_nodelet.cpp # files ending whth _nodelet will end up as part of the nodelet library
│ └── example_package_ros_tool # python modules have to go to src/<package_name>.
│ ├── node_module_python.py # These files can provide the node implementation for the scripts
│ └── __init__.py
└── test # The unittests
├── test_node.cpp # Every pair of .cpp and .test files represents one rostest
├── test_node.test
├── test.cpp # A cpp file without a matching .test a normal unittest and launched without ROS
├── node_python_test.py # Same for .py and .test files with the same name. The .py file must be executable!
└── node_python_test.test
For a normal, non-ros executable the structure is similar, but simpler. Every folder in the src file will become the name of an executable, and all cpp files within it will be part of the executable.
Generating code coverage
By default, your project is compiled without code coverage information. This can be changed by setting the cmake parameter MRT_ENABLE_COVERAGE
(e.g. by configuring cmake with -DMRT_ENABLE_COVERAGE=true
).
Setting this requires a recompilation of the project.
If this is set, running the run_tests
target will run the unittests and afterwards automatically generate an html coverage report.
The location is printed in the command line. If you set MRT_ENABLE_COVERAGE=2
, it will also be opened in firefox afterwards.
Sanitizing your code
The Sanitizers Asan, Tsan and UBsan are great ways of detecting bugs at runtime.
Sadly, you cannot enable them all as once, because Tsan cannot be used together with Asan and UBsan.
You can enable them similarly to the code coverage by setting the MRT_SANITIZER
cmake variable. It has two possible values:
- checks (enables Asan and UBsan)
- check_race (enables tsan)
If one of the sanitzers discovers an error at runtime, it will be printed to cerr.
Using clang-tidy
Clang-tidy checks your code statically at compile time for patterns of unsave or wrong code. Using this feature requires clang-tidy to be installed.
You might also want to provide a .clang-tidy file within your project that enables the checks of your choice. Refere to clang-tidys documentation for details.
You can enable clang-tidy by setting the CMake variable MRT_CLANG_TIDY
.
If you set it to “check”, clang-tidy will be run at compile time alongside the normal compiler and print all issues as compiler errors. If you set it to “fix” the recommended fixes will be applied directly to your code. Careful: Not all fixes ensure that the code compiles. Also the “fix” mode of clang-tidy is not thread safe, meaning that if you compile with multiple threads, multiple clang-tidy instances might try to fix the same file at the same time.
How dependency resolution works in detail
The mrt_cmake_modules parse your manifest file (i.e. package.xml
) in order to figure out your dependencies. The following lines in the CMakeLists.txt
are responsible for this:
find_package(mrt_cmake_modules REQUIRED) # finds this module
include(UseMrtStdCompilerFlags) # sets some generally useful compiler/warning flags
include(GatherDeps) # collects your dependencies and writes them into DEPENDEND_PACKAGES
find_package(AutoDeps REQUIRED COMPONENTS ${DEPENDEND_PACKAGES}) # resolves your dependencies by calling find_package appropriately.
AutoDeps then figures out, which includes, libraries and targets are needed in order to build this package.
The result is written into MRT_INCLUDE_DIRS
, MRT_LIBRARIES
and MRT_LIBRARY_DIRS
. These variables should be passed to the cmake targets.
The magic that happens under the hood can be understood by looking at the cmake.yaml within this project. It defines, for which dependency in the package.xml which findscript has to be searched and what variables
it will set by the script if successful. These will then be appended to the MRT_*
variables.
CMake API
This package contains a lot of useful cmake functions that are automatically available in all packages using the mrt_cmake_modules as dependency, e.g. mrt_install()
, mrt_add_node_and_nodelet()
, mrt_add_library()
, etc.
The automatically generated file already makes use of them, but you can also use them in your custom CMakeLists.
See here for a full documentation.
Findscripts
This package also contains a collection of find-scripts for thirdparty dependencies that are usually not shipped with a findscript. These are required by AutoDeps.
Going further
After you have saved time writing cmake boilerplate, it is now time to also save time writing ROS boilerplate. You might want to look into the rosinterface_handler as well. It is already intergrated in the CMakeLists template.
All you have to do is write a .rosif
file, and this project will automatically handle reading parameters from the parameter server, creating subscribers and publishers and handling reconfigure callbacks for you!
Changelog for package mrt_cmake_modules
1.0.11 (2024-09-20)
- Merge pull request #38 from nobleo/fix/find-flann-cmake-module fix(FindFLANN): set(FLANN_FOUND ON) if target already defined
- Contributors: keroe
1.0.10 (2024-07-26)
- FindGeographicLib: Fix for GeographicLib 2.* and Windows Since GeographicLib version 2, the library name changed from [libGeographic.so]{.title-ref} to [libGeographicLib.so]{.title-ref}, see https://github.com/geographiclib/geographiclib/blob/5e4425da84a46eb70e59656d71b4c99732a570ec/NEWS#L208 . To ensure that GeographicLib 2.* is found correcty, I think we should add also [GeographicLib]{.title-ref} to the names used by [find_library]{.title-ref}. Furthermore, on Windows the import library is called [GeographicLib-i.lib]{.title-ref} (see https://github.com/geographiclib/geographiclib/blob/v2.3/src/CMakeLists.txt#L119), so to find the library correctly on Windows we also look for GeographicLib-i .
- add ortools
- Revert "mrt_add_library now adds a compilation tests for all headers used by the library" This reverts commit b05cac0200ce6b8de8e8a18789dbd58cd9d8d1eb.
- Merge branch 'master' into HEAD
- Changes how the check for formatting is done. Now the CI job uses the --check flag provided by cmake_format instead of the [git diff]{.title-ref} check, because git caused some problems in this repo.
- format
- mrt_add_library now adds a compilation tests for all headers used by the library
- Add ZeroMQ
- Add zxing-cpp to cmake.yaml.
- hard coded ignore files which start with "mocs_compilation and delete the corresponding gcda file, because otherwise our current coverage pipeline fails.
- Contributors: Fabian Poggenhans, Jan-Hendrik Pauls, Johannes Beck, Kevin Rösch, Mrt Builder, Yinzhe Shen
1.0.9 (2021-11-26)
- Set python version
- Set PYTHON_EXECUTABLE for rolling
- Add find script and cmake.yml entry for proj.
- Update FLANN find script to work with newer versions.
- add boost iostreams component
- Removed debug message.
- Fix find boost python for cmake 3.20.
- add xerces and curl to camke.yaml
- Fix warnings in CUDA code.
- Remove cmake 3.20-only syntax
- Headers from dependencies are no longer marked as system, except from overlayed workspaces
- Set the ccache base dir as environment variable of the compiler command
- add pangolin
- Fix formatting of test failures on python3
- Fix recovering from sanitizer issues by making sure the flag is set only once resolves MRT/draft/simulation_adenauerring#34
- fix action build
- Use mrt_cgal again (brings a newer version than ubuntu)
- Adding or-tools to cmake.yaml.
- Sanitizers: enable recovering form nullptr issues even in no_recover mode this fixes otherwise unfixable issues e.g. in boost::serialization using this
- Update/remove old maintainer emails
- Improve evaluation of conditions in package.xml in order to make it more compliant with REP149
- Increase character limits for conditions specified package.xml This is necessary so that conditions that are based on ROS_DISTRO can be specified
- Add cmake entry for libnlopt-cpp-dev, new for focal
- Fix python script installation (shebang replacement)
- Add mrt_casadi to cmake.yaml
- Add mrt_hpipm to cmake.yaml
- Add mrt_blasfeo to cmake.yaml
- Add a small Readme pointing to cmake-format
- change name to match internal name
- add mrt-osqp-eigen
- add osqp
- Fix aravis find script.
- Switch to use aravis 0.8.
- Contributors: Fabian Poggenhans, Ilia Baltashov, Johannes Beck, Kevin Rösch, Maximilian Naumann, Piotr Orzechowski, Bernd Kröper, wep21
1.0.8 (2020-09-30)
- Fix finding boost python on versions with old cmake but new boost
- Contributors: Fabian Poggenhans
1.0.7 (2020-09-30)
- Fix versioning of sofiles
- Ensure unittests use the right gtest include dir
- Contributors: Fabian Poggenhans
1.0.6 (2020-09-30)
- Fix boost python building for python3
- Contributors: Fabian Poggenhans
1.0.5 (2020-09-29)
- Fix build for ROS2, gtest should no longer be installed in ROS2 mode
- Improve python nosetest info
- Update boost-python depend message
- Fix python module setup
- Packages can now have both a python module and a python api
- Add qtbase5-dev key
- Contributors: Fabian Poggenhans, Kevin Rösch, Maximilian Naumann
1.0.4 (2020-08-12)
- Deleted deprecated configuration files
- Fix cuda host compiler used for cuda 11
- Fix __init__.py template for python3
- Fix target handling for ros2
- Fix build failures on ROS1
- Fix the conan support
- Add a dependency on ros_environment to ensure ROS_VERSION is set
- Default to building shared libraries
- Add QtScript to the list of qt components
- Change license to BSD
- Remove traces of GPL-licensed libgps
- Remove unnecessary includes of cuda files
- Update tensorflow c findscript to set new tensorflow include paths
- Add cuda support for node and nodelet.
- Remove usage of ast package for evaulating package.xml conditions
- Fix crash if eval_coverage.py runs with python3
- Ensure that coverage is also generated for cpp code called from plain rostests
- Contributors: Fabian Poggenhans, Ilia Baltashov, Sven Richter
1.0.3 (2020-05-25)
- Replace deprecated platform.distro call with distro module
- Raise required CMake version to 3.0.2 to suppress warning with Noetic
- Remove boost signals component that is no longer part of boost
- Fixed c++14 test path include.
- Fix installation of python api files
- Update README.md
- Reformat with new version of cmake-format
- Add lcov as dependency again
- Fix FindBoostPython.cmake for cmake below 3.11 and python3
- Fix multiple include of MrtPCL
- Contributors: Christian-Eike Framing, Fabian Poggenhans, Johannes Beck, Johannes Janosovits, Moritz Cremer
1.0.2 (2020-03-24)
- Fix PCL findscript, disable precompiling
- added jsoncpp
- Make sure packages search for mrt_cmake_modules in their package config
- Fix resolution of packages in underlaying workspaces
- Mention rosdoc.yaml in package.xml
- Contributors: Fabian Poggenhans, Johannes Beck, Johannes Janosovits
1.0.1 (2020-03-11)
- Update maintainer
- Update generate_dependency_file to search CMAKE_PREFIX_PATH for packages instead of ROS_PACKAGE_PATH
- Update package xml to contain ROS urls and use format 3 to specify python version specific deps
- Add a rosdoc file so that ros can build the cmake api
- Contributors: Fabian Poggenhans
1.0.0 (2020-02-24)
- Initial release for ROS
- Contributors: Andre-Marcel Hellmund, Claudio Bandera, Fabian Poggenhans, Johannes Beck, Johannes Graeter, Niels Ole Salscheider, Piotr Orzechowski
Wiki Tutorials
Package Dependencies
Deps | Name |
---|---|
catkin | |
ament_cmake_core | |
ros_environment | |
gtest_vendor |
System Dependencies
Launch files
Messages
Services
Plugins
Recent questions tagged mrt_cmake_modules at Robotics Stack Exchange
mrt_cmake_modules package from mrt_cmake_modules repomrt_cmake_modules |
|
Package Summary
Tags | No category tags. |
Version | 1.0.11 |
License | BSD |
Build type | CATKIN |
Use | RECOMMENDED |
Repository Summary
Checkout URI | https://github.com/KIT-MRT/mrt_cmake_modules.git |
VCS Type | git |
VCS Version | master |
Last Updated | 2024-09-20 |
Dev Status | MAINTAINED |
CI status | No Continuous Integration |
Released | RELEASED |
Tags | No category tags. |
Contributing |
Help Wanted (0)
Good First Issues (0) Pull Requests to Review (0) |
Package Description
Additional Links
Maintainers
- Kevin Rösch
- Fabian Poggenhans
Authors
- Fabian Poggenhans
- Johannes Beck
MRT CMake Modules (Massively Reduced Time writing CMake Modules(*))
Maintainer status: maintained
- Maintainer: Kevin Rösch, Fabian Poggenhans
- Author: Johannes Beck, Claudio Bandera, Fabian Poggenhans
- License: BSD, some files MIT
- Bug / feature tracker: https://gitlab.mrt.uni-karlsruhe.de/MRT/mrt_cmake_modules/issues
- Source: git https://gitlab.mrt.uni-karlsruhe.de/MRT/mrt_cmake_modules.git (branch: master)
Imagine you whould never have to write a CMakeLists.txt file again. Never forget to install everything, no need to update it whenever you add a file, not time lost for figuring out how to call and use find_package
for your dependencies, etc.
Well, this is exactly what mrt_cmake_modules
do for you! The only thing you have to do is:
- Keep your files in a fixed structure,
- keep library and executable code in separate packages and
- make sure the package.xml actually contains all the packages you depend on.
If you don’t want to agree to this, there are ways to get this done as well. This will require you to modify our template file a bit.
On the other hand, you get a lot of things for free:
- Resolution of your dependencies in CMake
- Automatic generation of Nodes/Nodelets
- Supports C++ and Python(2/3)
- Python bindings for pybind11/boost-python
- Automated unittest detection and execution (including ROS tests)
- Automated code coverage generation
- Support for sanitizers
- Support for running clang-tidy
- Automated install of your scripts/launchfiles/executables/libraries… to the correct location
- experimental support for ROS2 and Conan builds
) Actually MRT stands for *Institut für Mess- und Regelungstechnik, the institute that develops this package.
Building
mrt_cmake_modules
is kept as leightweight as possible. It just contains a few CMake (and python) scripts. Its only dependency is catkin
and lcov
(for code coverage).
Getting started
Interested? In order to get the CMake template file, you have to run a small script: rosrun mrt_cmake_modules generate_cmakelists.py <package_name> [--ros] [--exe]
.
This will create a CMakeLists.txt file ready to be used in your project. We distinguish four different types of packages (this the --ros
and --exe
flags):
-
Library package: They have no dependency to ros (except catkin). Their goal is to either build a
lib<package>.so
, contain only headers, contain a python module, contain python bindings. Or a mixture of these. And unittests, of course. - Ros library package (–ros): Similar to the above, but can also contain message, action or configuration files
- Executable package (–exe): Provides either a number of executables, scripts or python modules for these scripts. And unittests of course.
- Node/Nodelet package (–ros –exe): Provides a number of nodes or nodelets, python nodes and launchfiles. And rostests of course.
Package structure
The best way to understand how packages have to be layed out is to have a look at the tree of an example package, and what it implies on the build.
Libraries
Here is the structure of a package called example_package
. It works out of the box with a CMakeLists.txt created with generate_cmakelists.py example_package --ros
:
.
├── CMakeLists.txt # The generated CMakeLists
├── include # The headers of this package. Available in the whole package
│ └── example_package # It is a ROS convention to keep them within include/<package_name>
│ ├── a_header.hpp
│ └── internal # Headers here are only to be used within cpp files of this package
│ └── internal_header.hpp
├── msg
│ └── a_message.msg # Messages files that will be automatically generated (only available for --ros)
├── package.xml # You should know that. Should contain at least pybind11-dev for the bindings
├── python_api # Folder for python bindings. Every file here becoms a module
│ ├── python_bindings.cpp # Will be available as "import example_package.python_bindings"
│ └── more_python_bindings.cpp # Refer to the pybind11 doc for the content of this file
├── README.md # The readme
├── src # Every cpp file in this filder will become part of libexample_package.so
│ ├── examplefile.cpp
│ ├── onemorefile.cpp
│ └── example_package # Python modules have to go to src/<package_name>
│ ├── pythonmodule.py # Will be available as "import example_package.pythonmodule"
│ └── __init__.py
└── test # Contains the unittests. Will be executed when running the test or run_tests target
├── test_example_package.cpp # Every file here will be a separate unittest executable
└── test_pyapi.py # Every py file that matches the testMatch regular expression will be executed
# using nosetest. Executables are ignored. See https://nose.readthedocs.io/
Note that everything in this structure is optional and can be left away if you don’t need it (except for the CMakeLists.txt of course).
Executables, Nodes and Nodelets
Here is the structure of a package called example_package_ros_tool
.
It works out of the box with a CMakeLists.txt created with generate_cmakelists.py example_package_ros_tool --exe --ros
:
.
├── CMakeLists.txt
├── cfg
│ └── ConfigFile.cfg # Files to be passed to dynamic_reconfigure
├── launch # Contains launch files provided by this package
│ ├── some_node.launch
│ ├── some_nodelet.launch
│ ├── some_python_node.launch
│ └── params # Contains parameter files that will be installed
│ ├── some_parameters.yaml
│ └── some_python_parameters.yaml
├── nodelet_plugins.xml # Should reference the nodelet library at lib/lib<package_name>-<nodename>-nodelet
├── package.xml # The manifest. It should reference the nodelet_plugins.xml
├── README.md
├── scripts # Executable scripts that will be installed. These can be python nodes as well
│ ├── bias_python_node.py
│ └── bias_script.sh
├── src # Every folder in here will be a node/nodelet or both
│ ├── nodename # nodename is the name of the node/nodelet
│ │ ├── somefile.cpp # Files compiled into the node and the nodelet
│ │ ├── somefile.hpp
│ │ ├── some_node.cpp # files ending with _node will end up being compiled into the node executable
│ │ └── a_nodelet.cpp # files ending whth _nodelet will end up as part of the nodelet library
│ └── example_package_ros_tool # python modules have to go to src/<package_name>.
│ ├── node_module_python.py # These files can provide the node implementation for the scripts
│ └── __init__.py
└── test # The unittests
├── test_node.cpp # Every pair of .cpp and .test files represents one rostest
├── test_node.test
├── test.cpp # A cpp file without a matching .test a normal unittest and launched without ROS
├── node_python_test.py # Same for .py and .test files with the same name. The .py file must be executable!
└── node_python_test.test
For a normal, non-ros executable the structure is similar, but simpler. Every folder in the src file will become the name of an executable, and all cpp files within it will be part of the executable.
Generating code coverage
By default, your project is compiled without code coverage information. This can be changed by setting the cmake parameter MRT_ENABLE_COVERAGE
(e.g. by configuring cmake with -DMRT_ENABLE_COVERAGE=true
).
Setting this requires a recompilation of the project.
If this is set, running the run_tests
target will run the unittests and afterwards automatically generate an html coverage report.
The location is printed in the command line. If you set MRT_ENABLE_COVERAGE=2
, it will also be opened in firefox afterwards.
Sanitizing your code
The Sanitizers Asan, Tsan and UBsan are great ways of detecting bugs at runtime.
Sadly, you cannot enable them all as once, because Tsan cannot be used together with Asan and UBsan.
You can enable them similarly to the code coverage by setting the MRT_SANITIZER
cmake variable. It has two possible values:
- checks (enables Asan and UBsan)
- check_race (enables tsan)
If one of the sanitzers discovers an error at runtime, it will be printed to cerr.
Using clang-tidy
Clang-tidy checks your code statically at compile time for patterns of unsave or wrong code. Using this feature requires clang-tidy to be installed.
You might also want to provide a .clang-tidy file within your project that enables the checks of your choice. Refere to clang-tidys documentation for details.
You can enable clang-tidy by setting the CMake variable MRT_CLANG_TIDY
.
If you set it to “check”, clang-tidy will be run at compile time alongside the normal compiler and print all issues as compiler errors. If you set it to “fix” the recommended fixes will be applied directly to your code. Careful: Not all fixes ensure that the code compiles. Also the “fix” mode of clang-tidy is not thread safe, meaning that if you compile with multiple threads, multiple clang-tidy instances might try to fix the same file at the same time.
How dependency resolution works in detail
The mrt_cmake_modules parse your manifest file (i.e. package.xml
) in order to figure out your dependencies. The following lines in the CMakeLists.txt
are responsible for this:
find_package(mrt_cmake_modules REQUIRED) # finds this module
include(UseMrtStdCompilerFlags) # sets some generally useful compiler/warning flags
include(GatherDeps) # collects your dependencies and writes them into DEPENDEND_PACKAGES
find_package(AutoDeps REQUIRED COMPONENTS ${DEPENDEND_PACKAGES}) # resolves your dependencies by calling find_package appropriately.
AutoDeps then figures out, which includes, libraries and targets are needed in order to build this package.
The result is written into MRT_INCLUDE_DIRS
, MRT_LIBRARIES
and MRT_LIBRARY_DIRS
. These variables should be passed to the cmake targets.
The magic that happens under the hood can be understood by looking at the cmake.yaml within this project. It defines, for which dependency in the package.xml which findscript has to be searched and what variables
it will set by the script if successful. These will then be appended to the MRT_*
variables.
CMake API
This package contains a lot of useful cmake functions that are automatically available in all packages using the mrt_cmake_modules as dependency, e.g. mrt_install()
, mrt_add_node_and_nodelet()
, mrt_add_library()
, etc.
The automatically generated file already makes use of them, but you can also use them in your custom CMakeLists.
See here for a full documentation.
Findscripts
This package also contains a collection of find-scripts for thirdparty dependencies that are usually not shipped with a findscript. These are required by AutoDeps.
Going further
After you have saved time writing cmake boilerplate, it is now time to also save time writing ROS boilerplate. You might want to look into the rosinterface_handler as well. It is already intergrated in the CMakeLists template.
All you have to do is write a .rosif
file, and this project will automatically handle reading parameters from the parameter server, creating subscribers and publishers and handling reconfigure callbacks for you!
Changelog for package mrt_cmake_modules
1.0.11 (2024-09-20)
- Merge pull request #38 from nobleo/fix/find-flann-cmake-module fix(FindFLANN): set(FLANN_FOUND ON) if target already defined
- Contributors: keroe
1.0.10 (2024-07-26)
- FindGeographicLib: Fix for GeographicLib 2.* and Windows Since GeographicLib version 2, the library name changed from [libGeographic.so]{.title-ref} to [libGeographicLib.so]{.title-ref}, see https://github.com/geographiclib/geographiclib/blob/5e4425da84a46eb70e59656d71b4c99732a570ec/NEWS#L208 . To ensure that GeographicLib 2.* is found correcty, I think we should add also [GeographicLib]{.title-ref} to the names used by [find_library]{.title-ref}. Furthermore, on Windows the import library is called [GeographicLib-i.lib]{.title-ref} (see https://github.com/geographiclib/geographiclib/blob/v2.3/src/CMakeLists.txt#L119), so to find the library correctly on Windows we also look for GeographicLib-i .
- add ortools
- Revert "mrt_add_library now adds a compilation tests for all headers used by the library" This reverts commit b05cac0200ce6b8de8e8a18789dbd58cd9d8d1eb.
- Merge branch 'master' into HEAD
- Changes how the check for formatting is done. Now the CI job uses the --check flag provided by cmake_format instead of the [git diff]{.title-ref} check, because git caused some problems in this repo.
- format
- mrt_add_library now adds a compilation tests for all headers used by the library
- Add ZeroMQ
- Add zxing-cpp to cmake.yaml.
- hard coded ignore files which start with "mocs_compilation and delete the corresponding gcda file, because otherwise our current coverage pipeline fails.
- Contributors: Fabian Poggenhans, Jan-Hendrik Pauls, Johannes Beck, Kevin Rösch, Mrt Builder, Yinzhe Shen
1.0.9 (2021-11-26)
- Set python version
- Set PYTHON_EXECUTABLE for rolling
- Add find script and cmake.yml entry for proj.
- Update FLANN find script to work with newer versions.
- add boost iostreams component
- Removed debug message.
- Fix find boost python for cmake 3.20.
- add xerces and curl to camke.yaml
- Fix warnings in CUDA code.
- Remove cmake 3.20-only syntax
- Headers from dependencies are no longer marked as system, except from overlayed workspaces
- Set the ccache base dir as environment variable of the compiler command
- add pangolin
- Fix formatting of test failures on python3
- Fix recovering from sanitizer issues by making sure the flag is set only once resolves MRT/draft/simulation_adenauerring#34
- fix action build
- Use mrt_cgal again (brings a newer version than ubuntu)
- Adding or-tools to cmake.yaml.
- Sanitizers: enable recovering form nullptr issues even in no_recover mode this fixes otherwise unfixable issues e.g. in boost::serialization using this
- Update/remove old maintainer emails
- Improve evaluation of conditions in package.xml in order to make it more compliant with REP149
- Increase character limits for conditions specified package.xml This is necessary so that conditions that are based on ROS_DISTRO can be specified
- Add cmake entry for libnlopt-cpp-dev, new for focal
- Fix python script installation (shebang replacement)
- Add mrt_casadi to cmake.yaml
- Add mrt_hpipm to cmake.yaml
- Add mrt_blasfeo to cmake.yaml
- Add a small Readme pointing to cmake-format
- change name to match internal name
- add mrt-osqp-eigen
- add osqp
- Fix aravis find script.
- Switch to use aravis 0.8.
- Contributors: Fabian Poggenhans, Ilia Baltashov, Johannes Beck, Kevin Rösch, Maximilian Naumann, Piotr Orzechowski, Bernd Kröper, wep21
1.0.8 (2020-09-30)
- Fix finding boost python on versions with old cmake but new boost
- Contributors: Fabian Poggenhans
1.0.7 (2020-09-30)
- Fix versioning of sofiles
- Ensure unittests use the right gtest include dir
- Contributors: Fabian Poggenhans
1.0.6 (2020-09-30)
- Fix boost python building for python3
- Contributors: Fabian Poggenhans
1.0.5 (2020-09-29)
- Fix build for ROS2, gtest should no longer be installed in ROS2 mode
- Improve python nosetest info
- Update boost-python depend message
- Fix python module setup
- Packages can now have both a python module and a python api
- Add qtbase5-dev key
- Contributors: Fabian Poggenhans, Kevin Rösch, Maximilian Naumann
1.0.4 (2020-08-12)
- Deleted deprecated configuration files
- Fix cuda host compiler used for cuda 11
- Fix __init__.py template for python3
- Fix target handling for ros2
- Fix build failures on ROS1
- Fix the conan support
- Add a dependency on ros_environment to ensure ROS_VERSION is set
- Default to building shared libraries
- Add QtScript to the list of qt components
- Change license to BSD
- Remove traces of GPL-licensed libgps
- Remove unnecessary includes of cuda files
- Update tensorflow c findscript to set new tensorflow include paths
- Add cuda support for node and nodelet.
- Remove usage of ast package for evaulating package.xml conditions
- Fix crash if eval_coverage.py runs with python3
- Ensure that coverage is also generated for cpp code called from plain rostests
- Contributors: Fabian Poggenhans, Ilia Baltashov, Sven Richter
1.0.3 (2020-05-25)
- Replace deprecated platform.distro call with distro module
- Raise required CMake version to 3.0.2 to suppress warning with Noetic
- Remove boost signals component that is no longer part of boost
- Fixed c++14 test path include.
- Fix installation of python api files
- Update README.md
- Reformat with new version of cmake-format
- Add lcov as dependency again
- Fix FindBoostPython.cmake for cmake below 3.11 and python3
- Fix multiple include of MrtPCL
- Contributors: Christian-Eike Framing, Fabian Poggenhans, Johannes Beck, Johannes Janosovits, Moritz Cremer
1.0.2 (2020-03-24)
- Fix PCL findscript, disable precompiling
- added jsoncpp
- Make sure packages search for mrt_cmake_modules in their package config
- Fix resolution of packages in underlaying workspaces
- Mention rosdoc.yaml in package.xml
- Contributors: Fabian Poggenhans, Johannes Beck, Johannes Janosovits
1.0.1 (2020-03-11)
- Update maintainer
- Update generate_dependency_file to search CMAKE_PREFIX_PATH for packages instead of ROS_PACKAGE_PATH
- Update package xml to contain ROS urls and use format 3 to specify python version specific deps
- Add a rosdoc file so that ros can build the cmake api
- Contributors: Fabian Poggenhans
1.0.0 (2020-02-24)
- Initial release for ROS
- Contributors: Andre-Marcel Hellmund, Claudio Bandera, Fabian Poggenhans, Johannes Beck, Johannes Graeter, Niels Ole Salscheider, Piotr Orzechowski
Wiki Tutorials
Package Dependencies
Deps | Name |
---|---|
catkin | |
ament_cmake_core | |
ros_environment | |
gtest_vendor |
System Dependencies
Launch files
Messages
Services
Plugins
Recent questions tagged mrt_cmake_modules at Robotics Stack Exchange
mrt_cmake_modules package from mrt_cmake_modules repomrt_cmake_modules |
|
Package Summary
Tags | No category tags. |
Version | 1.0.11 |
License | BSD |
Build type | CATKIN |
Use | RECOMMENDED |
Repository Summary
Checkout URI | https://github.com/KIT-MRT/mrt_cmake_modules.git |
VCS Type | git |
VCS Version | master |
Last Updated | 2024-09-20 |
Dev Status | MAINTAINED |
CI status | No Continuous Integration |
Released | RELEASED |
Tags | No category tags. |
Contributing |
Help Wanted (0)
Good First Issues (0) Pull Requests to Review (0) |
Package Description
Additional Links
Maintainers
- Kevin Rösch
- Fabian Poggenhans
Authors
- Fabian Poggenhans
- Johannes Beck
MRT CMake Modules (Massively Reduced Time writing CMake Modules(*))
Maintainer status: maintained
- Maintainer: Kevin Rösch, Fabian Poggenhans
- Author: Johannes Beck, Claudio Bandera, Fabian Poggenhans
- License: BSD, some files MIT
- Bug / feature tracker: https://gitlab.mrt.uni-karlsruhe.de/MRT/mrt_cmake_modules/issues
- Source: git https://gitlab.mrt.uni-karlsruhe.de/MRT/mrt_cmake_modules.git (branch: master)
Imagine you whould never have to write a CMakeLists.txt file again. Never forget to install everything, no need to update it whenever you add a file, not time lost for figuring out how to call and use find_package
for your dependencies, etc.
Well, this is exactly what mrt_cmake_modules
do for you! The only thing you have to do is:
- Keep your files in a fixed structure,
- keep library and executable code in separate packages and
- make sure the package.xml actually contains all the packages you depend on.
If you don’t want to agree to this, there are ways to get this done as well. This will require you to modify our template file a bit.
On the other hand, you get a lot of things for free:
- Resolution of your dependencies in CMake
- Automatic generation of Nodes/Nodelets
- Supports C++ and Python(2/3)
- Python bindings for pybind11/boost-python
- Automated unittest detection and execution (including ROS tests)
- Automated code coverage generation
- Support for sanitizers
- Support for running clang-tidy
- Automated install of your scripts/launchfiles/executables/libraries… to the correct location
- experimental support for ROS2 and Conan builds
) Actually MRT stands for *Institut für Mess- und Regelungstechnik, the institute that develops this package.
Building
mrt_cmake_modules
is kept as leightweight as possible. It just contains a few CMake (and python) scripts. Its only dependency is catkin
and lcov
(for code coverage).
Getting started
Interested? In order to get the CMake template file, you have to run a small script: rosrun mrt_cmake_modules generate_cmakelists.py <package_name> [--ros] [--exe]
.
This will create a CMakeLists.txt file ready to be used in your project. We distinguish four different types of packages (this the --ros
and --exe
flags):
-
Library package: They have no dependency to ros (except catkin). Their goal is to either build a
lib<package>.so
, contain only headers, contain a python module, contain python bindings. Or a mixture of these. And unittests, of course. - Ros library package (–ros): Similar to the above, but can also contain message, action or configuration files
- Executable package (–exe): Provides either a number of executables, scripts or python modules for these scripts. And unittests of course.
- Node/Nodelet package (–ros –exe): Provides a number of nodes or nodelets, python nodes and launchfiles. And rostests of course.
Package structure
The best way to understand how packages have to be layed out is to have a look at the tree of an example package, and what it implies on the build.
Libraries
Here is the structure of a package called example_package
. It works out of the box with a CMakeLists.txt created with generate_cmakelists.py example_package --ros
:
.
├── CMakeLists.txt # The generated CMakeLists
├── include # The headers of this package. Available in the whole package
│ └── example_package # It is a ROS convention to keep them within include/<package_name>
│ ├── a_header.hpp
│ └── internal # Headers here are only to be used within cpp files of this package
│ └── internal_header.hpp
├── msg
│ └── a_message.msg # Messages files that will be automatically generated (only available for --ros)
├── package.xml # You should know that. Should contain at least pybind11-dev for the bindings
├── python_api # Folder for python bindings. Every file here becoms a module
│ ├── python_bindings.cpp # Will be available as "import example_package.python_bindings"
│ └── more_python_bindings.cpp # Refer to the pybind11 doc for the content of this file
├── README.md # The readme
├── src # Every cpp file in this filder will become part of libexample_package.so
│ ├── examplefile.cpp
│ ├── onemorefile.cpp
│ └── example_package # Python modules have to go to src/<package_name>
│ ├── pythonmodule.py # Will be available as "import example_package.pythonmodule"
│ └── __init__.py
└── test # Contains the unittests. Will be executed when running the test or run_tests target
├── test_example_package.cpp # Every file here will be a separate unittest executable
└── test_pyapi.py # Every py file that matches the testMatch regular expression will be executed
# using nosetest. Executables are ignored. See https://nose.readthedocs.io/
Note that everything in this structure is optional and can be left away if you don’t need it (except for the CMakeLists.txt of course).
Executables, Nodes and Nodelets
Here is the structure of a package called example_package_ros_tool
.
It works out of the box with a CMakeLists.txt created with generate_cmakelists.py example_package_ros_tool --exe --ros
:
.
├── CMakeLists.txt
├── cfg
│ └── ConfigFile.cfg # Files to be passed to dynamic_reconfigure
├── launch # Contains launch files provided by this package
│ ├── some_node.launch
│ ├── some_nodelet.launch
│ ├── some_python_node.launch
│ └── params # Contains parameter files that will be installed
│ ├── some_parameters.yaml
│ └── some_python_parameters.yaml
├── nodelet_plugins.xml # Should reference the nodelet library at lib/lib<package_name>-<nodename>-nodelet
├── package.xml # The manifest. It should reference the nodelet_plugins.xml
├── README.md
├── scripts # Executable scripts that will be installed. These can be python nodes as well
│ ├── bias_python_node.py
│ └── bias_script.sh
├── src # Every folder in here will be a node/nodelet or both
│ ├── nodename # nodename is the name of the node/nodelet
│ │ ├── somefile.cpp # Files compiled into the node and the nodelet
│ │ ├── somefile.hpp
│ │ ├── some_node.cpp # files ending with _node will end up being compiled into the node executable
│ │ └── a_nodelet.cpp # files ending whth _nodelet will end up as part of the nodelet library
│ └── example_package_ros_tool # python modules have to go to src/<package_name>.
│ ├── node_module_python.py # These files can provide the node implementation for the scripts
│ └── __init__.py
└── test # The unittests
├── test_node.cpp # Every pair of .cpp and .test files represents one rostest
├── test_node.test
├── test.cpp # A cpp file without a matching .test a normal unittest and launched without ROS
├── node_python_test.py # Same for .py and .test files with the same name. The .py file must be executable!
└── node_python_test.test
For a normal, non-ros executable the structure is similar, but simpler. Every folder in the src file will become the name of an executable, and all cpp files within it will be part of the executable.
Generating code coverage
By default, your project is compiled without code coverage information. This can be changed by setting the cmake parameter MRT_ENABLE_COVERAGE
(e.g. by configuring cmake with -DMRT_ENABLE_COVERAGE=true
).
Setting this requires a recompilation of the project.
If this is set, running the run_tests
target will run the unittests and afterwards automatically generate an html coverage report.
The location is printed in the command line. If you set MRT_ENABLE_COVERAGE=2
, it will also be opened in firefox afterwards.
Sanitizing your code
The Sanitizers Asan, Tsan and UBsan are great ways of detecting bugs at runtime.
Sadly, you cannot enable them all as once, because Tsan cannot be used together with Asan and UBsan.
You can enable them similarly to the code coverage by setting the MRT_SANITIZER
cmake variable. It has two possible values:
- checks (enables Asan and UBsan)
- check_race (enables tsan)
If one of the sanitzers discovers an error at runtime, it will be printed to cerr.
Using clang-tidy
Clang-tidy checks your code statically at compile time for patterns of unsave or wrong code. Using this feature requires clang-tidy to be installed.
You might also want to provide a .clang-tidy file within your project that enables the checks of your choice. Refere to clang-tidys documentation for details.
You can enable clang-tidy by setting the CMake variable MRT_CLANG_TIDY
.
If you set it to “check”, clang-tidy will be run at compile time alongside the normal compiler and print all issues as compiler errors. If you set it to “fix” the recommended fixes will be applied directly to your code. Careful: Not all fixes ensure that the code compiles. Also the “fix” mode of clang-tidy is not thread safe, meaning that if you compile with multiple threads, multiple clang-tidy instances might try to fix the same file at the same time.
How dependency resolution works in detail
The mrt_cmake_modules parse your manifest file (i.e. package.xml
) in order to figure out your dependencies. The following lines in the CMakeLists.txt
are responsible for this:
find_package(mrt_cmake_modules REQUIRED) # finds this module
include(UseMrtStdCompilerFlags) # sets some generally useful compiler/warning flags
include(GatherDeps) # collects your dependencies and writes them into DEPENDEND_PACKAGES
find_package(AutoDeps REQUIRED COMPONENTS ${DEPENDEND_PACKAGES}) # resolves your dependencies by calling find_package appropriately.
AutoDeps then figures out, which includes, libraries and targets are needed in order to build this package.
The result is written into MRT_INCLUDE_DIRS
, MRT_LIBRARIES
and MRT_LIBRARY_DIRS
. These variables should be passed to the cmake targets.
The magic that happens under the hood can be understood by looking at the cmake.yaml within this project. It defines, for which dependency in the package.xml which findscript has to be searched and what variables
it will set by the script if successful. These will then be appended to the MRT_*
variables.
CMake API
This package contains a lot of useful cmake functions that are automatically available in all packages using the mrt_cmake_modules as dependency, e.g. mrt_install()
, mrt_add_node_and_nodelet()
, mrt_add_library()
, etc.
The automatically generated file already makes use of them, but you can also use them in your custom CMakeLists.
See here for a full documentation.
Findscripts
This package also contains a collection of find-scripts for thirdparty dependencies that are usually not shipped with a findscript. These are required by AutoDeps.
Going further
After you have saved time writing cmake boilerplate, it is now time to also save time writing ROS boilerplate. You might want to look into the rosinterface_handler as well. It is already intergrated in the CMakeLists template.
All you have to do is write a .rosif
file, and this project will automatically handle reading parameters from the parameter server, creating subscribers and publishers and handling reconfigure callbacks for you!
Changelog for package mrt_cmake_modules
1.0.11 (2024-09-20)
- Merge pull request #38 from nobleo/fix/find-flann-cmake-module fix(FindFLANN): set(FLANN_FOUND ON) if target already defined
- Contributors: keroe
1.0.10 (2024-07-26)
- FindGeographicLib: Fix for GeographicLib 2.* and Windows Since GeographicLib version 2, the library name changed from [libGeographic.so]{.title-ref} to [libGeographicLib.so]{.title-ref}, see https://github.com/geographiclib/geographiclib/blob/5e4425da84a46eb70e59656d71b4c99732a570ec/NEWS#L208 . To ensure that GeographicLib 2.* is found correcty, I think we should add also [GeographicLib]{.title-ref} to the names used by [find_library]{.title-ref}. Furthermore, on Windows the import library is called [GeographicLib-i.lib]{.title-ref} (see https://github.com/geographiclib/geographiclib/blob/v2.3/src/CMakeLists.txt#L119), so to find the library correctly on Windows we also look for GeographicLib-i .
- add ortools
- Revert "mrt_add_library now adds a compilation tests for all headers used by the library" This reverts commit b05cac0200ce6b8de8e8a18789dbd58cd9d8d1eb.
- Merge branch 'master' into HEAD
- Changes how the check for formatting is done. Now the CI job uses the --check flag provided by cmake_format instead of the [git diff]{.title-ref} check, because git caused some problems in this repo.
- format
- mrt_add_library now adds a compilation tests for all headers used by the library
- Add ZeroMQ
- Add zxing-cpp to cmake.yaml.
- hard coded ignore files which start with "mocs_compilation and delete the corresponding gcda file, because otherwise our current coverage pipeline fails.
- Contributors: Fabian Poggenhans, Jan-Hendrik Pauls, Johannes Beck, Kevin Rösch, Mrt Builder, Yinzhe Shen
1.0.9 (2021-11-26)
- Set python version
- Set PYTHON_EXECUTABLE for rolling
- Add find script and cmake.yml entry for proj.
- Update FLANN find script to work with newer versions.
- add boost iostreams component
- Removed debug message.
- Fix find boost python for cmake 3.20.
- add xerces and curl to camke.yaml
- Fix warnings in CUDA code.
- Remove cmake 3.20-only syntax
- Headers from dependencies are no longer marked as system, except from overlayed workspaces
- Set the ccache base dir as environment variable of the compiler command
- add pangolin
- Fix formatting of test failures on python3
- Fix recovering from sanitizer issues by making sure the flag is set only once resolves MRT/draft/simulation_adenauerring#34
- fix action build
- Use mrt_cgal again (brings a newer version than ubuntu)
- Adding or-tools to cmake.yaml.
- Sanitizers: enable recovering form nullptr issues even in no_recover mode this fixes otherwise unfixable issues e.g. in boost::serialization using this
- Update/remove old maintainer emails
- Improve evaluation of conditions in package.xml in order to make it more compliant with REP149
- Increase character limits for conditions specified package.xml This is necessary so that conditions that are based on ROS_DISTRO can be specified
- Add cmake entry for libnlopt-cpp-dev, new for focal
- Fix python script installation (shebang replacement)
- Add mrt_casadi to cmake.yaml
- Add mrt_hpipm to cmake.yaml
- Add mrt_blasfeo to cmake.yaml
- Add a small Readme pointing to cmake-format
- change name to match internal name
- add mrt-osqp-eigen
- add osqp
- Fix aravis find script.
- Switch to use aravis 0.8.
- Contributors: Fabian Poggenhans, Ilia Baltashov, Johannes Beck, Kevin Rösch, Maximilian Naumann, Piotr Orzechowski, Bernd Kröper, wep21
1.0.8 (2020-09-30)
- Fix finding boost python on versions with old cmake but new boost
- Contributors: Fabian Poggenhans
1.0.7 (2020-09-30)
- Fix versioning of sofiles
- Ensure unittests use the right gtest include dir
- Contributors: Fabian Poggenhans
1.0.6 (2020-09-30)
- Fix boost python building for python3
- Contributors: Fabian Poggenhans
1.0.5 (2020-09-29)
- Fix build for ROS2, gtest should no longer be installed in ROS2 mode
- Improve python nosetest info
- Update boost-python depend message
- Fix python module setup
- Packages can now have both a python module and a python api
- Add qtbase5-dev key
- Contributors: Fabian Poggenhans, Kevin Rösch, Maximilian Naumann
1.0.4 (2020-08-12)
- Deleted deprecated configuration files
- Fix cuda host compiler used for cuda 11
- Fix __init__.py template for python3
- Fix target handling for ros2
- Fix build failures on ROS1
- Fix the conan support
- Add a dependency on ros_environment to ensure ROS_VERSION is set
- Default to building shared libraries
- Add QtScript to the list of qt components
- Change license to BSD
- Remove traces of GPL-licensed libgps
- Remove unnecessary includes of cuda files
- Update tensorflow c findscript to set new tensorflow include paths
- Add cuda support for node and nodelet.
- Remove usage of ast package for evaulating package.xml conditions
- Fix crash if eval_coverage.py runs with python3
- Ensure that coverage is also generated for cpp code called from plain rostests
- Contributors: Fabian Poggenhans, Ilia Baltashov, Sven Richter
1.0.3 (2020-05-25)
- Replace deprecated platform.distro call with distro module
- Raise required CMake version to 3.0.2 to suppress warning with Noetic
- Remove boost signals component that is no longer part of boost
- Fixed c++14 test path include.
- Fix installation of python api files
- Update README.md
- Reformat with new version of cmake-format
- Add lcov as dependency again
- Fix FindBoostPython.cmake for cmake below 3.11 and python3
- Fix multiple include of MrtPCL
- Contributors: Christian-Eike Framing, Fabian Poggenhans, Johannes Beck, Johannes Janosovits, Moritz Cremer
1.0.2 (2020-03-24)
- Fix PCL findscript, disable precompiling
- added jsoncpp
- Make sure packages search for mrt_cmake_modules in their package config
- Fix resolution of packages in underlaying workspaces
- Mention rosdoc.yaml in package.xml
- Contributors: Fabian Poggenhans, Johannes Beck, Johannes Janosovits
1.0.1 (2020-03-11)
- Update maintainer
- Update generate_dependency_file to search CMAKE_PREFIX_PATH for packages instead of ROS_PACKAGE_PATH
- Update package xml to contain ROS urls and use format 3 to specify python version specific deps
- Add a rosdoc file so that ros can build the cmake api
- Contributors: Fabian Poggenhans
1.0.0 (2020-02-24)
- Initial release for ROS
- Contributors: Andre-Marcel Hellmund, Claudio Bandera, Fabian Poggenhans, Johannes Beck, Johannes Graeter, Niels Ole Salscheider, Piotr Orzechowski
Wiki Tutorials
Package Dependencies
Deps | Name |
---|---|
catkin | |
ament_cmake_core | |
ros_environment | |
gtest_vendor |
System Dependencies
Launch files
Messages
Services
Plugins
Recent questions tagged mrt_cmake_modules at Robotics Stack Exchange
mrt_cmake_modules package from mrt_cmake_modules repomrt_cmake_modules |
|
Package Summary
Tags | No category tags. |
Version | 1.0.11 |
License | BSD |
Build type | CATKIN |
Use | RECOMMENDED |
Repository Summary
Checkout URI | https://github.com/KIT-MRT/mrt_cmake_modules.git |
VCS Type | git |
VCS Version | master |
Last Updated | 2024-09-20 |
Dev Status | MAINTAINED |
CI status | No Continuous Integration |
Released | RELEASED |
Tags | No category tags. |
Contributing |
Help Wanted (0)
Good First Issues (0) Pull Requests to Review (0) |
Package Description
Additional Links
Maintainers
- Kevin Rösch
- Fabian Poggenhans
Authors
- Fabian Poggenhans
- Johannes Beck
MRT CMake Modules (Massively Reduced Time writing CMake Modules(*))
Maintainer status: maintained
- Maintainer: Kevin Rösch, Fabian Poggenhans
- Author: Johannes Beck, Claudio Bandera, Fabian Poggenhans
- License: BSD, some files MIT
- Bug / feature tracker: https://gitlab.mrt.uni-karlsruhe.de/MRT/mrt_cmake_modules/issues
- Source: git https://gitlab.mrt.uni-karlsruhe.de/MRT/mrt_cmake_modules.git (branch: master)
Imagine you whould never have to write a CMakeLists.txt file again. Never forget to install everything, no need to update it whenever you add a file, not time lost for figuring out how to call and use find_package
for your dependencies, etc.
Well, this is exactly what mrt_cmake_modules
do for you! The only thing you have to do is:
- Keep your files in a fixed structure,
- keep library and executable code in separate packages and
- make sure the package.xml actually contains all the packages you depend on.
If you don’t want to agree to this, there are ways to get this done as well. This will require you to modify our template file a bit.
On the other hand, you get a lot of things for free:
- Resolution of your dependencies in CMake
- Automatic generation of Nodes/Nodelets
- Supports C++ and Python(2/3)
- Python bindings for pybind11/boost-python
- Automated unittest detection and execution (including ROS tests)
- Automated code coverage generation
- Support for sanitizers
- Support for running clang-tidy
- Automated install of your scripts/launchfiles/executables/libraries… to the correct location
- experimental support for ROS2 and Conan builds
) Actually MRT stands for *Institut für Mess- und Regelungstechnik, the institute that develops this package.
Building
mrt_cmake_modules
is kept as leightweight as possible. It just contains a few CMake (and python) scripts. Its only dependency is catkin
and lcov
(for code coverage).
Getting started
Interested? In order to get the CMake template file, you have to run a small script: rosrun mrt_cmake_modules generate_cmakelists.py <package_name> [--ros] [--exe]
.
This will create a CMakeLists.txt file ready to be used in your project. We distinguish four different types of packages (this the --ros
and --exe
flags):
-
Library package: They have no dependency to ros (except catkin). Their goal is to either build a
lib<package>.so
, contain only headers, contain a python module, contain python bindings. Or a mixture of these. And unittests, of course. - Ros library package (–ros): Similar to the above, but can also contain message, action or configuration files
- Executable package (–exe): Provides either a number of executables, scripts or python modules for these scripts. And unittests of course.
- Node/Nodelet package (–ros –exe): Provides a number of nodes or nodelets, python nodes and launchfiles. And rostests of course.
Package structure
The best way to understand how packages have to be layed out is to have a look at the tree of an example package, and what it implies on the build.
Libraries
Here is the structure of a package called example_package
. It works out of the box with a CMakeLists.txt created with generate_cmakelists.py example_package --ros
:
.
├── CMakeLists.txt # The generated CMakeLists
├── include # The headers of this package. Available in the whole package
│ └── example_package # It is a ROS convention to keep them within include/<package_name>
│ ├── a_header.hpp
│ └── internal # Headers here are only to be used within cpp files of this package
│ └── internal_header.hpp
├── msg
│ └── a_message.msg # Messages files that will be automatically generated (only available for --ros)
├── package.xml # You should know that. Should contain at least pybind11-dev for the bindings
├── python_api # Folder for python bindings. Every file here becoms a module
│ ├── python_bindings.cpp # Will be available as "import example_package.python_bindings"
│ └── more_python_bindings.cpp # Refer to the pybind11 doc for the content of this file
├── README.md # The readme
├── src # Every cpp file in this filder will become part of libexample_package.so
│ ├── examplefile.cpp
│ ├── onemorefile.cpp
│ └── example_package # Python modules have to go to src/<package_name>
│ ├── pythonmodule.py # Will be available as "import example_package.pythonmodule"
│ └── __init__.py
└── test # Contains the unittests. Will be executed when running the test or run_tests target
├── test_example_package.cpp # Every file here will be a separate unittest executable
└── test_pyapi.py # Every py file that matches the testMatch regular expression will be executed
# using nosetest. Executables are ignored. See https://nose.readthedocs.io/
Note that everything in this structure is optional and can be left away if you don’t need it (except for the CMakeLists.txt of course).
Executables, Nodes and Nodelets
Here is the structure of a package called example_package_ros_tool
.
It works out of the box with a CMakeLists.txt created with generate_cmakelists.py example_package_ros_tool --exe --ros
:
.
├── CMakeLists.txt
├── cfg
│ └── ConfigFile.cfg # Files to be passed to dynamic_reconfigure
├── launch # Contains launch files provided by this package
│ ├── some_node.launch
│ ├── some_nodelet.launch
│ ├── some_python_node.launch
│ └── params # Contains parameter files that will be installed
│ ├── some_parameters.yaml
│ └── some_python_parameters.yaml
├── nodelet_plugins.xml # Should reference the nodelet library at lib/lib<package_name>-<nodename>-nodelet
├── package.xml # The manifest. It should reference the nodelet_plugins.xml
├── README.md
├── scripts # Executable scripts that will be installed. These can be python nodes as well
│ ├── bias_python_node.py
│ └── bias_script.sh
├── src # Every folder in here will be a node/nodelet or both
│ ├── nodename # nodename is the name of the node/nodelet
│ │ ├── somefile.cpp # Files compiled into the node and the nodelet
│ │ ├── somefile.hpp
│ │ ├── some_node.cpp # files ending with _node will end up being compiled into the node executable
│ │ └── a_nodelet.cpp # files ending whth _nodelet will end up as part of the nodelet library
│ └── example_package_ros_tool # python modules have to go to src/<package_name>.
│ ├── node_module_python.py # These files can provide the node implementation for the scripts
│ └── __init__.py
└── test # The unittests
├── test_node.cpp # Every pair of .cpp and .test files represents one rostest
├── test_node.test
├── test.cpp # A cpp file without a matching .test a normal unittest and launched without ROS
├── node_python_test.py # Same for .py and .test files with the same name. The .py file must be executable!
└── node_python_test.test
For a normal, non-ros executable the structure is similar, but simpler. Every folder in the src file will become the name of an executable, and all cpp files within it will be part of the executable.
Generating code coverage
By default, your project is compiled without code coverage information. This can be changed by setting the cmake parameter MRT_ENABLE_COVERAGE
(e.g. by configuring cmake with -DMRT_ENABLE_COVERAGE=true
).
Setting this requires a recompilation of the project.
If this is set, running the run_tests
target will run the unittests and afterwards automatically generate an html coverage report.
The location is printed in the command line. If you set MRT_ENABLE_COVERAGE=2
, it will also be opened in firefox afterwards.
Sanitizing your code
The Sanitizers Asan, Tsan and UBsan are great ways of detecting bugs at runtime.
Sadly, you cannot enable them all as once, because Tsan cannot be used together with Asan and UBsan.
You can enable them similarly to the code coverage by setting the MRT_SANITIZER
cmake variable. It has two possible values:
- checks (enables Asan and UBsan)
- check_race (enables tsan)
If one of the sanitzers discovers an error at runtime, it will be printed to cerr.
Using clang-tidy
Clang-tidy checks your code statically at compile time for patterns of unsave or wrong code. Using this feature requires clang-tidy to be installed.
You might also want to provide a .clang-tidy file within your project that enables the checks of your choice. Refere to clang-tidys documentation for details.
You can enable clang-tidy by setting the CMake variable MRT_CLANG_TIDY
.
If you set it to “check”, clang-tidy will be run at compile time alongside the normal compiler and print all issues as compiler errors. If you set it to “fix” the recommended fixes will be applied directly to your code. Careful: Not all fixes ensure that the code compiles. Also the “fix” mode of clang-tidy is not thread safe, meaning that if you compile with multiple threads, multiple clang-tidy instances might try to fix the same file at the same time.
How dependency resolution works in detail
The mrt_cmake_modules parse your manifest file (i.e. package.xml
) in order to figure out your dependencies. The following lines in the CMakeLists.txt
are responsible for this:
find_package(mrt_cmake_modules REQUIRED) # finds this module
include(UseMrtStdCompilerFlags) # sets some generally useful compiler/warning flags
include(GatherDeps) # collects your dependencies and writes them into DEPENDEND_PACKAGES
find_package(AutoDeps REQUIRED COMPONENTS ${DEPENDEND_PACKAGES}) # resolves your dependencies by calling find_package appropriately.
AutoDeps then figures out, which includes, libraries and targets are needed in order to build this package.
The result is written into MRT_INCLUDE_DIRS
, MRT_LIBRARIES
and MRT_LIBRARY_DIRS
. These variables should be passed to the cmake targets.
The magic that happens under the hood can be understood by looking at the cmake.yaml within this project. It defines, for which dependency in the package.xml which findscript has to be searched and what variables
it will set by the script if successful. These will then be appended to the MRT_*
variables.
CMake API
This package contains a lot of useful cmake functions that are automatically available in all packages using the mrt_cmake_modules as dependency, e.g. mrt_install()
, mrt_add_node_and_nodelet()
, mrt_add_library()
, etc.
The automatically generated file already makes use of them, but you can also use them in your custom CMakeLists.
See here for a full documentation.
Findscripts
This package also contains a collection of find-scripts for thirdparty dependencies that are usually not shipped with a findscript. These are required by AutoDeps.
Going further
After you have saved time writing cmake boilerplate, it is now time to also save time writing ROS boilerplate. You might want to look into the rosinterface_handler as well. It is already intergrated in the CMakeLists template.
All you have to do is write a .rosif
file, and this project will automatically handle reading parameters from the parameter server, creating subscribers and publishers and handling reconfigure callbacks for you!
Changelog for package mrt_cmake_modules
1.0.11 (2024-09-20)
- Merge pull request #38 from nobleo/fix/find-flann-cmake-module fix(FindFLANN): set(FLANN_FOUND ON) if target already defined
- Contributors: keroe
1.0.10 (2024-07-26)
- FindGeographicLib: Fix for GeographicLib 2.* and Windows Since GeographicLib version 2, the library name changed from [libGeographic.so]{.title-ref} to [libGeographicLib.so]{.title-ref}, see https://github.com/geographiclib/geographiclib/blob/5e4425da84a46eb70e59656d71b4c99732a570ec/NEWS#L208 . To ensure that GeographicLib 2.* is found correcty, I think we should add also [GeographicLib]{.title-ref} to the names used by [find_library]{.title-ref}. Furthermore, on Windows the import library is called [GeographicLib-i.lib]{.title-ref} (see https://github.com/geographiclib/geographiclib/blob/v2.3/src/CMakeLists.txt#L119), so to find the library correctly on Windows we also look for GeographicLib-i .
- add ortools
- Revert "mrt_add_library now adds a compilation tests for all headers used by the library" This reverts commit b05cac0200ce6b8de8e8a18789dbd58cd9d8d1eb.
- Merge branch 'master' into HEAD
- Changes how the check for formatting is done. Now the CI job uses the --check flag provided by cmake_format instead of the [git diff]{.title-ref} check, because git caused some problems in this repo.
- format
- mrt_add_library now adds a compilation tests for all headers used by the library
- Add ZeroMQ
- Add zxing-cpp to cmake.yaml.
- hard coded ignore files which start with "mocs_compilation and delete the corresponding gcda file, because otherwise our current coverage pipeline fails.
- Contributors: Fabian Poggenhans, Jan-Hendrik Pauls, Johannes Beck, Kevin Rösch, Mrt Builder, Yinzhe Shen
1.0.9 (2021-11-26)
- Set python version
- Set PYTHON_EXECUTABLE for rolling
- Add find script and cmake.yml entry for proj.
- Update FLANN find script to work with newer versions.
- add boost iostreams component
- Removed debug message.
- Fix find boost python for cmake 3.20.
- add xerces and curl to camke.yaml
- Fix warnings in CUDA code.
- Remove cmake 3.20-only syntax
- Headers from dependencies are no longer marked as system, except from overlayed workspaces
- Set the ccache base dir as environment variable of the compiler command
- add pangolin
- Fix formatting of test failures on python3
- Fix recovering from sanitizer issues by making sure the flag is set only once resolves MRT/draft/simulation_adenauerring#34
- fix action build
- Use mrt_cgal again (brings a newer version than ubuntu)
- Adding or-tools to cmake.yaml.
- Sanitizers: enable recovering form nullptr issues even in no_recover mode this fixes otherwise unfixable issues e.g. in boost::serialization using this
- Update/remove old maintainer emails
- Improve evaluation of conditions in package.xml in order to make it more compliant with REP149
- Increase character limits for conditions specified package.xml This is necessary so that conditions that are based on ROS_DISTRO can be specified
- Add cmake entry for libnlopt-cpp-dev, new for focal
- Fix python script installation (shebang replacement)
- Add mrt_casadi to cmake.yaml
- Add mrt_hpipm to cmake.yaml
- Add mrt_blasfeo to cmake.yaml
- Add a small Readme pointing to cmake-format
- change name to match internal name
- add mrt-osqp-eigen
- add osqp
- Fix aravis find script.
- Switch to use aravis 0.8.
- Contributors: Fabian Poggenhans, Ilia Baltashov, Johannes Beck, Kevin Rösch, Maximilian Naumann, Piotr Orzechowski, Bernd Kröper, wep21
1.0.8 (2020-09-30)
- Fix finding boost python on versions with old cmake but new boost
- Contributors: Fabian Poggenhans
1.0.7 (2020-09-30)
- Fix versioning of sofiles
- Ensure unittests use the right gtest include dir
- Contributors: Fabian Poggenhans
1.0.6 (2020-09-30)
- Fix boost python building for python3
- Contributors: Fabian Poggenhans
1.0.5 (2020-09-29)
- Fix build for ROS2, gtest should no longer be installed in ROS2 mode
- Improve python nosetest info
- Update boost-python depend message
- Fix python module setup
- Packages can now have both a python module and a python api
- Add qtbase5-dev key
- Contributors: Fabian Poggenhans, Kevin Rösch, Maximilian Naumann
1.0.4 (2020-08-12)
- Deleted deprecated configuration files
- Fix cuda host compiler used for cuda 11
- Fix __init__.py template for python3
- Fix target handling for ros2
- Fix build failures on ROS1
- Fix the conan support
- Add a dependency on ros_environment to ensure ROS_VERSION is set
- Default to building shared libraries
- Add QtScript to the list of qt components
- Change license to BSD
- Remove traces of GPL-licensed libgps
- Remove unnecessary includes of cuda files
- Update tensorflow c findscript to set new tensorflow include paths
- Add cuda support for node and nodelet.
- Remove usage of ast package for evaulating package.xml conditions
- Fix crash if eval_coverage.py runs with python3
- Ensure that coverage is also generated for cpp code called from plain rostests
- Contributors: Fabian Poggenhans, Ilia Baltashov, Sven Richter
1.0.3 (2020-05-25)
- Replace deprecated platform.distro call with distro module
- Raise required CMake version to 3.0.2 to suppress warning with Noetic
- Remove boost signals component that is no longer part of boost
- Fixed c++14 test path include.
- Fix installation of python api files
- Update README.md
- Reformat with new version of cmake-format
- Add lcov as dependency again
- Fix FindBoostPython.cmake for cmake below 3.11 and python3
- Fix multiple include of MrtPCL
- Contributors: Christian-Eike Framing, Fabian Poggenhans, Johannes Beck, Johannes Janosovits, Moritz Cremer
1.0.2 (2020-03-24)
- Fix PCL findscript, disable precompiling
- added jsoncpp
- Make sure packages search for mrt_cmake_modules in their package config
- Fix resolution of packages in underlaying workspaces
- Mention rosdoc.yaml in package.xml
- Contributors: Fabian Poggenhans, Johannes Beck, Johannes Janosovits
1.0.1 (2020-03-11)
- Update maintainer
- Update generate_dependency_file to search CMAKE_PREFIX_PATH for packages instead of ROS_PACKAGE_PATH
- Update package xml to contain ROS urls and use format 3 to specify python version specific deps
- Add a rosdoc file so that ros can build the cmake api
- Contributors: Fabian Poggenhans
1.0.0 (2020-02-24)
- Initial release for ROS
- Contributors: Andre-Marcel Hellmund, Claudio Bandera, Fabian Poggenhans, Johannes Beck, Johannes Graeter, Niels Ole Salscheider, Piotr Orzechowski
Wiki Tutorials
Package Dependencies
Deps | Name |
---|---|
catkin | |
ament_cmake_core | |
ros_environment | |
gtest_vendor |
System Dependencies
Launch files
Messages
Services
Plugins
Recent questions tagged mrt_cmake_modules at Robotics Stack Exchange
mrt_cmake_modules package from mrt_cmake_modules repomrt_cmake_modules |
|
Package Summary
Tags | No category tags. |
Version | 1.0.11 |
License | BSD |
Build type | CATKIN |
Use | RECOMMENDED |
Repository Summary
Checkout URI | https://github.com/KIT-MRT/mrt_cmake_modules.git |
VCS Type | git |
VCS Version | master |
Last Updated | 2024-09-20 |
Dev Status | MAINTAINED |
CI status | Continuous Integration : 0 / 0 |
Released | RELEASED |
Tags | No category tags. |
Contributing |
Help Wanted (0)
Good First Issues (0) Pull Requests to Review (0) |
Package Description
Additional Links
Maintainers
- Kevin Rösch
- Fabian Poggenhans
Authors
- Fabian Poggenhans
- Johannes Beck
MRT CMake Modules (Massively Reduced Time writing CMake Modules(*))
Maintainer status: maintained
- Maintainer: Kevin Rösch, Fabian Poggenhans
- Author: Johannes Beck, Claudio Bandera, Fabian Poggenhans
- License: BSD, some files MIT
- Bug / feature tracker: https://gitlab.mrt.uni-karlsruhe.de/MRT/mrt_cmake_modules/issues
- Source: git https://gitlab.mrt.uni-karlsruhe.de/MRT/mrt_cmake_modules.git (branch: master)
Imagine you whould never have to write a CMakeLists.txt file again. Never forget to install everything, no need to update it whenever you add a file, not time lost for figuring out how to call and use find_package
for your dependencies, etc.
Well, this is exactly what mrt_cmake_modules
do for you! The only thing you have to do is:
- Keep your files in a fixed structure,
- keep library and executable code in separate packages and
- make sure the package.xml actually contains all the packages you depend on.
If you don’t want to agree to this, there are ways to get this done as well. This will require you to modify our template file a bit.
On the other hand, you get a lot of things for free:
- Resolution of your dependencies in CMake
- Automatic generation of Nodes/Nodelets
- Supports C++ and Python(2/3)
- Python bindings for pybind11/boost-python
- Automated unittest detection and execution (including ROS tests)
- Automated code coverage generation
- Support for sanitizers
- Support for running clang-tidy
- Automated install of your scripts/launchfiles/executables/libraries… to the correct location
- experimental support for ROS2 and Conan builds
) Actually MRT stands for *Institut für Mess- und Regelungstechnik, the institute that develops this package.
Building
mrt_cmake_modules
is kept as leightweight as possible. It just contains a few CMake (and python) scripts. Its only dependency is catkin
and lcov
(for code coverage).
Getting started
Interested? In order to get the CMake template file, you have to run a small script: rosrun mrt_cmake_modules generate_cmakelists.py <package_name> [--ros] [--exe]
.
This will create a CMakeLists.txt file ready to be used in your project. We distinguish four different types of packages (this the --ros
and --exe
flags):
-
Library package: They have no dependency to ros (except catkin). Their goal is to either build a
lib<package>.so
, contain only headers, contain a python module, contain python bindings. Or a mixture of these. And unittests, of course. - Ros library package (–ros): Similar to the above, but can also contain message, action or configuration files
- Executable package (–exe): Provides either a number of executables, scripts or python modules for these scripts. And unittests of course.
- Node/Nodelet package (–ros –exe): Provides a number of nodes or nodelets, python nodes and launchfiles. And rostests of course.
Package structure
The best way to understand how packages have to be layed out is to have a look at the tree of an example package, and what it implies on the build.
Libraries
Here is the structure of a package called example_package
. It works out of the box with a CMakeLists.txt created with generate_cmakelists.py example_package --ros
:
.
├── CMakeLists.txt # The generated CMakeLists
├── include # The headers of this package. Available in the whole package
│ └── example_package # It is a ROS convention to keep them within include/<package_name>
│ ├── a_header.hpp
│ └── internal # Headers here are only to be used within cpp files of this package
│ └── internal_header.hpp
├── msg
│ └── a_message.msg # Messages files that will be automatically generated (only available for --ros)
├── package.xml # You should know that. Should contain at least pybind11-dev for the bindings
├── python_api # Folder for python bindings. Every file here becoms a module
│ ├── python_bindings.cpp # Will be available as "import example_package.python_bindings"
│ └── more_python_bindings.cpp # Refer to the pybind11 doc for the content of this file
├── README.md # The readme
├── src # Every cpp file in this filder will become part of libexample_package.so
│ ├── examplefile.cpp
│ ├── onemorefile.cpp
│ └── example_package # Python modules have to go to src/<package_name>
│ ├── pythonmodule.py # Will be available as "import example_package.pythonmodule"
│ └── __init__.py
└── test # Contains the unittests. Will be executed when running the test or run_tests target
├── test_example_package.cpp # Every file here will be a separate unittest executable
└── test_pyapi.py # Every py file that matches the testMatch regular expression will be executed
# using nosetest. Executables are ignored. See https://nose.readthedocs.io/
Note that everything in this structure is optional and can be left away if you don’t need it (except for the CMakeLists.txt of course).
Executables, Nodes and Nodelets
Here is the structure of a package called example_package_ros_tool
.
It works out of the box with a CMakeLists.txt created with generate_cmakelists.py example_package_ros_tool --exe --ros
:
.
├── CMakeLists.txt
├── cfg
│ └── ConfigFile.cfg # Files to be passed to dynamic_reconfigure
├── launch # Contains launch files provided by this package
│ ├── some_node.launch
│ ├── some_nodelet.launch
│ ├── some_python_node.launch
│ └── params # Contains parameter files that will be installed
│ ├── some_parameters.yaml
│ └── some_python_parameters.yaml
├── nodelet_plugins.xml # Should reference the nodelet library at lib/lib<package_name>-<nodename>-nodelet
├── package.xml # The manifest. It should reference the nodelet_plugins.xml
├── README.md
├── scripts # Executable scripts that will be installed. These can be python nodes as well
│ ├── bias_python_node.py
│ └── bias_script.sh
├── src # Every folder in here will be a node/nodelet or both
│ ├── nodename # nodename is the name of the node/nodelet
│ │ ├── somefile.cpp # Files compiled into the node and the nodelet
│ │ ├── somefile.hpp
│ │ ├── some_node.cpp # files ending with _node will end up being compiled into the node executable
│ │ └── a_nodelet.cpp # files ending whth _nodelet will end up as part of the nodelet library
│ └── example_package_ros_tool # python modules have to go to src/<package_name>.
│ ├── node_module_python.py # These files can provide the node implementation for the scripts
│ └── __init__.py
└── test # The unittests
├── test_node.cpp # Every pair of .cpp and .test files represents one rostest
├── test_node.test
├── test.cpp # A cpp file without a matching .test a normal unittest and launched without ROS
├── node_python_test.py # Same for .py and .test files with the same name. The .py file must be executable!
└── node_python_test.test
For a normal, non-ros executable the structure is similar, but simpler. Every folder in the src file will become the name of an executable, and all cpp files within it will be part of the executable.
Generating code coverage
By default, your project is compiled without code coverage information. This can be changed by setting the cmake parameter MRT_ENABLE_COVERAGE
(e.g. by configuring cmake with -DMRT_ENABLE_COVERAGE=true
).
Setting this requires a recompilation of the project.
If this is set, running the run_tests
target will run the unittests and afterwards automatically generate an html coverage report.
The location is printed in the command line. If you set MRT_ENABLE_COVERAGE=2
, it will also be opened in firefox afterwards.
Sanitizing your code
The Sanitizers Asan, Tsan and UBsan are great ways of detecting bugs at runtime.
Sadly, you cannot enable them all as once, because Tsan cannot be used together with Asan and UBsan.
You can enable them similarly to the code coverage by setting the MRT_SANITIZER
cmake variable. It has two possible values:
- checks (enables Asan and UBsan)
- check_race (enables tsan)
If one of the sanitzers discovers an error at runtime, it will be printed to cerr.
Using clang-tidy
Clang-tidy checks your code statically at compile time for patterns of unsave or wrong code. Using this feature requires clang-tidy to be installed.
You might also want to provide a .clang-tidy file within your project that enables the checks of your choice. Refere to clang-tidys documentation for details.
You can enable clang-tidy by setting the CMake variable MRT_CLANG_TIDY
.
If you set it to “check”, clang-tidy will be run at compile time alongside the normal compiler and print all issues as compiler errors. If you set it to “fix” the recommended fixes will be applied directly to your code. Careful: Not all fixes ensure that the code compiles. Also the “fix” mode of clang-tidy is not thread safe, meaning that if you compile with multiple threads, multiple clang-tidy instances might try to fix the same file at the same time.
How dependency resolution works in detail
The mrt_cmake_modules parse your manifest file (i.e. package.xml
) in order to figure out your dependencies. The following lines in the CMakeLists.txt
are responsible for this:
find_package(mrt_cmake_modules REQUIRED) # finds this module
include(UseMrtStdCompilerFlags) # sets some generally useful compiler/warning flags
include(GatherDeps) # collects your dependencies and writes them into DEPENDEND_PACKAGES
find_package(AutoDeps REQUIRED COMPONENTS ${DEPENDEND_PACKAGES}) # resolves your dependencies by calling find_package appropriately.
AutoDeps then figures out, which includes, libraries and targets are needed in order to build this package.
The result is written into MRT_INCLUDE_DIRS
, MRT_LIBRARIES
and MRT_LIBRARY_DIRS
. These variables should be passed to the cmake targets.
The magic that happens under the hood can be understood by looking at the cmake.yaml within this project. It defines, for which dependency in the package.xml which findscript has to be searched and what variables
it will set by the script if successful. These will then be appended to the MRT_*
variables.
CMake API
This package contains a lot of useful cmake functions that are automatically available in all packages using the mrt_cmake_modules as dependency, e.g. mrt_install()
, mrt_add_node_and_nodelet()
, mrt_add_library()
, etc.
The automatically generated file already makes use of them, but you can also use them in your custom CMakeLists.
See here for a full documentation.
Findscripts
This package also contains a collection of find-scripts for thirdparty dependencies that are usually not shipped with a findscript. These are required by AutoDeps.
Going further
After you have saved time writing cmake boilerplate, it is now time to also save time writing ROS boilerplate. You might want to look into the rosinterface_handler as well. It is already intergrated in the CMakeLists template.
All you have to do is write a .rosif
file, and this project will automatically handle reading parameters from the parameter server, creating subscribers and publishers and handling reconfigure callbacks for you!
Changelog for package mrt_cmake_modules
1.0.11 (2024-09-20)
- Merge pull request #38 from nobleo/fix/find-flann-cmake-module fix(FindFLANN): set(FLANN_FOUND ON) if target already defined
- Contributors: keroe
1.0.10 (2024-07-26)
- FindGeographicLib: Fix for GeographicLib 2.* and Windows Since GeographicLib version 2, the library name changed from [libGeographic.so]{.title-ref} to [libGeographicLib.so]{.title-ref}, see https://github.com/geographiclib/geographiclib/blob/5e4425da84a46eb70e59656d71b4c99732a570ec/NEWS#L208 . To ensure that GeographicLib 2.* is found correcty, I think we should add also [GeographicLib]{.title-ref} to the names used by [find_library]{.title-ref}. Furthermore, on Windows the import library is called [GeographicLib-i.lib]{.title-ref} (see https://github.com/geographiclib/geographiclib/blob/v2.3/src/CMakeLists.txt#L119), so to find the library correctly on Windows we also look for GeographicLib-i .
- add ortools
- Revert "mrt_add_library now adds a compilation tests for all headers used by the library" This reverts commit b05cac0200ce6b8de8e8a18789dbd58cd9d8d1eb.
- Merge branch 'master' into HEAD
- Changes how the check for formatting is done. Now the CI job uses the --check flag provided by cmake_format instead of the [git diff]{.title-ref} check, because git caused some problems in this repo.
- format
- mrt_add_library now adds a compilation tests for all headers used by the library
- Add ZeroMQ
- Add zxing-cpp to cmake.yaml.
- hard coded ignore files which start with "mocs_compilation and delete the corresponding gcda file, because otherwise our current coverage pipeline fails.
- Contributors: Fabian Poggenhans, Jan-Hendrik Pauls, Johannes Beck, Kevin Rösch, Mrt Builder, Yinzhe Shen
1.0.9 (2021-11-26)
- Set python version
- Set PYTHON_EXECUTABLE for rolling
- Add find script and cmake.yml entry for proj.
- Update FLANN find script to work with newer versions.
- add boost iostreams component
- Removed debug message.
- Fix find boost python for cmake 3.20.
- add xerces and curl to camke.yaml
- Fix warnings in CUDA code.
- Remove cmake 3.20-only syntax
- Headers from dependencies are no longer marked as system, except from overlayed workspaces
- Set the ccache base dir as environment variable of the compiler command
- add pangolin
- Fix formatting of test failures on python3
- Fix recovering from sanitizer issues by making sure the flag is set only once resolves MRT/draft/simulation_adenauerring#34
- fix action build
- Use mrt_cgal again (brings a newer version than ubuntu)
- Adding or-tools to cmake.yaml.
- Sanitizers: enable recovering form nullptr issues even in no_recover mode this fixes otherwise unfixable issues e.g. in boost::serialization using this
- Update/remove old maintainer emails
- Improve evaluation of conditions in package.xml in order to make it more compliant with REP149
- Increase character limits for conditions specified package.xml This is necessary so that conditions that are based on ROS_DISTRO can be specified
- Add cmake entry for libnlopt-cpp-dev, new for focal
- Fix python script installation (shebang replacement)
- Add mrt_casadi to cmake.yaml
- Add mrt_hpipm to cmake.yaml
- Add mrt_blasfeo to cmake.yaml
- Add a small Readme pointing to cmake-format
- change name to match internal name
- add mrt-osqp-eigen
- add osqp
- Fix aravis find script.
- Switch to use aravis 0.8.
- Contributors: Fabian Poggenhans, Ilia Baltashov, Johannes Beck, Kevin Rösch, Maximilian Naumann, Piotr Orzechowski, Bernd Kröper, wep21
1.0.8 (2020-09-30)
- Fix finding boost python on versions with old cmake but new boost
- Contributors: Fabian Poggenhans
1.0.7 (2020-09-30)
- Fix versioning of sofiles
- Ensure unittests use the right gtest include dir
- Contributors: Fabian Poggenhans
1.0.6 (2020-09-30)
- Fix boost python building for python3
- Contributors: Fabian Poggenhans
1.0.5 (2020-09-29)
- Fix build for ROS2, gtest should no longer be installed in ROS2 mode
- Improve python nosetest info
- Update boost-python depend message
- Fix python module setup
- Packages can now have both a python module and a python api
- Add qtbase5-dev key
- Contributors: Fabian Poggenhans, Kevin Rösch, Maximilian Naumann
1.0.4 (2020-08-12)
- Deleted deprecated configuration files
- Fix cuda host compiler used for cuda 11
- Fix __init__.py template for python3
- Fix target handling for ros2
- Fix build failures on ROS1
- Fix the conan support
- Add a dependency on ros_environment to ensure ROS_VERSION is set
- Default to building shared libraries
- Add QtScript to the list of qt components
- Change license to BSD
- Remove traces of GPL-licensed libgps
- Remove unnecessary includes of cuda files
- Update tensorflow c findscript to set new tensorflow include paths
- Add cuda support for node and nodelet.
- Remove usage of ast package for evaulating package.xml conditions
- Fix crash if eval_coverage.py runs with python3
- Ensure that coverage is also generated for cpp code called from plain rostests
- Contributors: Fabian Poggenhans, Ilia Baltashov, Sven Richter
1.0.3 (2020-05-25)
- Replace deprecated platform.distro call with distro module
- Raise required CMake version to 3.0.2 to suppress warning with Noetic
- Remove boost signals component that is no longer part of boost
- Fixed c++14 test path include.
- Fix installation of python api files
- Update README.md
- Reformat with new version of cmake-format
- Add lcov as dependency again
- Fix FindBoostPython.cmake for cmake below 3.11 and python3
- Fix multiple include of MrtPCL
- Contributors: Christian-Eike Framing, Fabian Poggenhans, Johannes Beck, Johannes Janosovits, Moritz Cremer
1.0.2 (2020-03-24)
- Fix PCL findscript, disable precompiling
- added jsoncpp
- Make sure packages search for mrt_cmake_modules in their package config
- Fix resolution of packages in underlaying workspaces
- Mention rosdoc.yaml in package.xml
- Contributors: Fabian Poggenhans, Johannes Beck, Johannes Janosovits
1.0.1 (2020-03-11)
- Update maintainer
- Update generate_dependency_file to search CMAKE_PREFIX_PATH for packages instead of ROS_PACKAGE_PATH
- Update package xml to contain ROS urls and use format 3 to specify python version specific deps
- Add a rosdoc file so that ros can build the cmake api
- Contributors: Fabian Poggenhans
1.0.0 (2020-02-24)
- Initial release for ROS
- Contributors: Andre-Marcel Hellmund, Claudio Bandera, Fabian Poggenhans, Johannes Beck, Johannes Graeter, Niels Ole Salscheider, Piotr Orzechowski
Wiki Tutorials
Package Dependencies
Deps | Name |
---|---|
catkin | |
ament_cmake_core | |
ros_environment | |
gtest_vendor |
System Dependencies
Launch files
Messages
Services
Plugins
Recent questions tagged mrt_cmake_modules at Robotics Stack Exchange
mrt_cmake_modules package from mrt_cmake_modules repomrt_cmake_modules |
|
Package Summary
Tags | No category tags. |
Version | 1.0.11 |
License | BSD |
Build type | CATKIN |
Use | RECOMMENDED |
Repository Summary
Checkout URI | https://github.com/KIT-MRT/mrt_cmake_modules.git |
VCS Type | git |
VCS Version | master |
Last Updated | 2024-09-20 |
Dev Status | MAINTAINED |
CI status | No Continuous Integration |
Released | RELEASED |
Tags | No category tags. |
Contributing |
Help Wanted (0)
Good First Issues (0) Pull Requests to Review (0) |
Package Description
Additional Links
Maintainers
- Kevin Rösch
- Fabian Poggenhans
Authors
- Fabian Poggenhans
- Johannes Beck
MRT CMake Modules (Massively Reduced Time writing CMake Modules(*))
Maintainer status: maintained
- Maintainer: Kevin Rösch, Fabian Poggenhans
- Author: Johannes Beck, Claudio Bandera, Fabian Poggenhans
- License: BSD, some files MIT
- Bug / feature tracker: https://gitlab.mrt.uni-karlsruhe.de/MRT/mrt_cmake_modules/issues
- Source: git https://gitlab.mrt.uni-karlsruhe.de/MRT/mrt_cmake_modules.git (branch: master)
Imagine you whould never have to write a CMakeLists.txt file again. Never forget to install everything, no need to update it whenever you add a file, not time lost for figuring out how to call and use find_package
for your dependencies, etc.
Well, this is exactly what mrt_cmake_modules
do for you! The only thing you have to do is:
- Keep your files in a fixed structure,
- keep library and executable code in separate packages and
- make sure the package.xml actually contains all the packages you depend on.
If you don’t want to agree to this, there are ways to get this done as well. This will require you to modify our template file a bit.
On the other hand, you get a lot of things for free:
- Resolution of your dependencies in CMake
- Automatic generation of Nodes/Nodelets
- Supports C++ and Python(2/3)
- Python bindings for pybind11/boost-python
- Automated unittest detection and execution (including ROS tests)
- Automated code coverage generation
- Support for sanitizers
- Support for running clang-tidy
- Automated install of your scripts/launchfiles/executables/libraries… to the correct location
- experimental support for ROS2 and Conan builds
) Actually MRT stands for *Institut für Mess- und Regelungstechnik, the institute that develops this package.
Building
mrt_cmake_modules
is kept as leightweight as possible. It just contains a few CMake (and python) scripts. Its only dependency is catkin
and lcov
(for code coverage).
Getting started
Interested? In order to get the CMake template file, you have to run a small script: rosrun mrt_cmake_modules generate_cmakelists.py <package_name> [--ros] [--exe]
.
This will create a CMakeLists.txt file ready to be used in your project. We distinguish four different types of packages (this the --ros
and --exe
flags):
-
Library package: They have no dependency to ros (except catkin). Their goal is to either build a
lib<package>.so
, contain only headers, contain a python module, contain python bindings. Or a mixture of these. And unittests, of course. - Ros library package (–ros): Similar to the above, but can also contain message, action or configuration files
- Executable package (–exe): Provides either a number of executables, scripts or python modules for these scripts. And unittests of course.
- Node/Nodelet package (–ros –exe): Provides a number of nodes or nodelets, python nodes and launchfiles. And rostests of course.
Package structure
The best way to understand how packages have to be layed out is to have a look at the tree of an example package, and what it implies on the build.
Libraries
Here is the structure of a package called example_package
. It works out of the box with a CMakeLists.txt created with generate_cmakelists.py example_package --ros
:
.
├── CMakeLists.txt # The generated CMakeLists
├── include # The headers of this package. Available in the whole package
│ └── example_package # It is a ROS convention to keep them within include/<package_name>
│ ├── a_header.hpp
│ └── internal # Headers here are only to be used within cpp files of this package
│ └── internal_header.hpp
├── msg
│ └── a_message.msg # Messages files that will be automatically generated (only available for --ros)
├── package.xml # You should know that. Should contain at least pybind11-dev for the bindings
├── python_api # Folder for python bindings. Every file here becoms a module
│ ├── python_bindings.cpp # Will be available as "import example_package.python_bindings"
│ └── more_python_bindings.cpp # Refer to the pybind11 doc for the content of this file
├── README.md # The readme
├── src # Every cpp file in this filder will become part of libexample_package.so
│ ├── examplefile.cpp
│ ├── onemorefile.cpp
│ └── example_package # Python modules have to go to src/<package_name>
│ ├── pythonmodule.py # Will be available as "import example_package.pythonmodule"
│ └── __init__.py
└── test # Contains the unittests. Will be executed when running the test or run_tests target
├── test_example_package.cpp # Every file here will be a separate unittest executable
└── test_pyapi.py # Every py file that matches the testMatch regular expression will be executed
# using nosetest. Executables are ignored. See https://nose.readthedocs.io/
Note that everything in this structure is optional and can be left away if you don’t need it (except for the CMakeLists.txt of course).
Executables, Nodes and Nodelets
Here is the structure of a package called example_package_ros_tool
.
It works out of the box with a CMakeLists.txt created with generate_cmakelists.py example_package_ros_tool --exe --ros
:
.
├── CMakeLists.txt
├── cfg
│ └── ConfigFile.cfg # Files to be passed to dynamic_reconfigure
├── launch # Contains launch files provided by this package
│ ├── some_node.launch
│ ├── some_nodelet.launch
│ ├── some_python_node.launch
│ └── params # Contains parameter files that will be installed
│ ├── some_parameters.yaml
│ └── some_python_parameters.yaml
├── nodelet_plugins.xml # Should reference the nodelet library at lib/lib<package_name>-<nodename>-nodelet
├── package.xml # The manifest. It should reference the nodelet_plugins.xml
├── README.md
├── scripts # Executable scripts that will be installed. These can be python nodes as well
│ ├── bias_python_node.py
│ └── bias_script.sh
├── src # Every folder in here will be a node/nodelet or both
│ ├── nodename # nodename is the name of the node/nodelet
│ │ ├── somefile.cpp # Files compiled into the node and the nodelet
│ │ ├── somefile.hpp
│ │ ├── some_node.cpp # files ending with _node will end up being compiled into the node executable
│ │ └── a_nodelet.cpp # files ending whth _nodelet will end up as part of the nodelet library
│ └── example_package_ros_tool # python modules have to go to src/<package_name>.
│ ├── node_module_python.py # These files can provide the node implementation for the scripts
│ └── __init__.py
└── test # The unittests
├── test_node.cpp # Every pair of .cpp and .test files represents one rostest
├── test_node.test
├── test.cpp # A cpp file without a matching .test a normal unittest and launched without ROS
├── node_python_test.py # Same for .py and .test files with the same name. The .py file must be executable!
└── node_python_test.test
For a normal, non-ros executable the structure is similar, but simpler. Every folder in the src file will become the name of an executable, and all cpp files within it will be part of the executable.
Generating code coverage
By default, your project is compiled without code coverage information. This can be changed by setting the cmake parameter MRT_ENABLE_COVERAGE
(e.g. by configuring cmake with -DMRT_ENABLE_COVERAGE=true
).
Setting this requires a recompilation of the project.
If this is set, running the run_tests
target will run the unittests and afterwards automatically generate an html coverage report.
The location is printed in the command line. If you set MRT_ENABLE_COVERAGE=2
, it will also be opened in firefox afterwards.
Sanitizing your code
The Sanitizers Asan, Tsan and UBsan are great ways of detecting bugs at runtime.
Sadly, you cannot enable them all as once, because Tsan cannot be used together with Asan and UBsan.
You can enable them similarly to the code coverage by setting the MRT_SANITIZER
cmake variable. It has two possible values:
- checks (enables Asan and UBsan)
- check_race (enables tsan)
If one of the sanitzers discovers an error at runtime, it will be printed to cerr.
Using clang-tidy
Clang-tidy checks your code statically at compile time for patterns of unsave or wrong code. Using this feature requires clang-tidy to be installed.
You might also want to provide a .clang-tidy file within your project that enables the checks of your choice. Refere to clang-tidys documentation for details.
You can enable clang-tidy by setting the CMake variable MRT_CLANG_TIDY
.
If you set it to “check”, clang-tidy will be run at compile time alongside the normal compiler and print all issues as compiler errors. If you set it to “fix” the recommended fixes will be applied directly to your code. Careful: Not all fixes ensure that the code compiles. Also the “fix” mode of clang-tidy is not thread safe, meaning that if you compile with multiple threads, multiple clang-tidy instances might try to fix the same file at the same time.
How dependency resolution works in detail
The mrt_cmake_modules parse your manifest file (i.e. package.xml
) in order to figure out your dependencies. The following lines in the CMakeLists.txt
are responsible for this:
find_package(mrt_cmake_modules REQUIRED) # finds this module
include(UseMrtStdCompilerFlags) # sets some generally useful compiler/warning flags
include(GatherDeps) # collects your dependencies and writes them into DEPENDEND_PACKAGES
find_package(AutoDeps REQUIRED COMPONENTS ${DEPENDEND_PACKAGES}) # resolves your dependencies by calling find_package appropriately.
AutoDeps then figures out, which includes, libraries and targets are needed in order to build this package.
The result is written into MRT_INCLUDE_DIRS
, MRT_LIBRARIES
and MRT_LIBRARY_DIRS
. These variables should be passed to the cmake targets.
The magic that happens under the hood can be understood by looking at the cmake.yaml within this project. It defines, for which dependency in the package.xml which findscript has to be searched and what variables
it will set by the script if successful. These will then be appended to the MRT_*
variables.
CMake API
This package contains a lot of useful cmake functions that are automatically available in all packages using the mrt_cmake_modules as dependency, e.g. mrt_install()
, mrt_add_node_and_nodelet()
, mrt_add_library()
, etc.
The automatically generated file already makes use of them, but you can also use them in your custom CMakeLists.
See here for a full documentation.
Findscripts
This package also contains a collection of find-scripts for thirdparty dependencies that are usually not shipped with a findscript. These are required by AutoDeps.
Going further
After you have saved time writing cmake boilerplate, it is now time to also save time writing ROS boilerplate. You might want to look into the rosinterface_handler as well. It is already intergrated in the CMakeLists template.
All you have to do is write a .rosif
file, and this project will automatically handle reading parameters from the parameter server, creating subscribers and publishers and handling reconfigure callbacks for you!
Changelog for package mrt_cmake_modules
1.0.11 (2024-09-20)
- Merge pull request #38 from nobleo/fix/find-flann-cmake-module fix(FindFLANN): set(FLANN_FOUND ON) if target already defined
- Contributors: keroe
1.0.10 (2024-07-26)
- FindGeographicLib: Fix for GeographicLib 2.* and Windows Since GeographicLib version 2, the library name changed from [libGeographic.so]{.title-ref} to [libGeographicLib.so]{.title-ref}, see https://github.com/geographiclib/geographiclib/blob/5e4425da84a46eb70e59656d71b4c99732a570ec/NEWS#L208 . To ensure that GeographicLib 2.* is found correcty, I think we should add also [GeographicLib]{.title-ref} to the names used by [find_library]{.title-ref}. Furthermore, on Windows the import library is called [GeographicLib-i.lib]{.title-ref} (see https://github.com/geographiclib/geographiclib/blob/v2.3/src/CMakeLists.txt#L119), so to find the library correctly on Windows we also look for GeographicLib-i .
- add ortools
- Revert "mrt_add_library now adds a compilation tests for all headers used by the library" This reverts commit b05cac0200ce6b8de8e8a18789dbd58cd9d8d1eb.
- Merge branch 'master' into HEAD
- Changes how the check for formatting is done. Now the CI job uses the --check flag provided by cmake_format instead of the [git diff]{.title-ref} check, because git caused some problems in this repo.
- format
- mrt_add_library now adds a compilation tests for all headers used by the library
- Add ZeroMQ
- Add zxing-cpp to cmake.yaml.
- hard coded ignore files which start with "mocs_compilation and delete the corresponding gcda file, because otherwise our current coverage pipeline fails.
- Contributors: Fabian Poggenhans, Jan-Hendrik Pauls, Johannes Beck, Kevin Rösch, Mrt Builder, Yinzhe Shen
1.0.9 (2021-11-26)
- Set python version
- Set PYTHON_EXECUTABLE for rolling
- Add find script and cmake.yml entry for proj.
- Update FLANN find script to work with newer versions.
- add boost iostreams component
- Removed debug message.
- Fix find boost python for cmake 3.20.
- add xerces and curl to camke.yaml
- Fix warnings in CUDA code.
- Remove cmake 3.20-only syntax
- Headers from dependencies are no longer marked as system, except from overlayed workspaces
- Set the ccache base dir as environment variable of the compiler command
- add pangolin
- Fix formatting of test failures on python3
- Fix recovering from sanitizer issues by making sure the flag is set only once resolves MRT/draft/simulation_adenauerring#34
- fix action build
- Use mrt_cgal again (brings a newer version than ubuntu)
- Adding or-tools to cmake.yaml.
- Sanitizers: enable recovering form nullptr issues even in no_recover mode this fixes otherwise unfixable issues e.g. in boost::serialization using this
- Update/remove old maintainer emails
- Improve evaluation of conditions in package.xml in order to make it more compliant with REP149
- Increase character limits for conditions specified package.xml This is necessary so that conditions that are based on ROS_DISTRO can be specified
- Add cmake entry for libnlopt-cpp-dev, new for focal
- Fix python script installation (shebang replacement)
- Add mrt_casadi to cmake.yaml
- Add mrt_hpipm to cmake.yaml
- Add mrt_blasfeo to cmake.yaml
- Add a small Readme pointing to cmake-format
- change name to match internal name
- add mrt-osqp-eigen
- add osqp
- Fix aravis find script.
- Switch to use aravis 0.8.
- Contributors: Fabian Poggenhans, Ilia Baltashov, Johannes Beck, Kevin Rösch, Maximilian Naumann, Piotr Orzechowski, Bernd Kröper, wep21
1.0.8 (2020-09-30)
- Fix finding boost python on versions with old cmake but new boost
- Contributors: Fabian Poggenhans
1.0.7 (2020-09-30)
- Fix versioning of sofiles
- Ensure unittests use the right gtest include dir
- Contributors: Fabian Poggenhans
1.0.6 (2020-09-30)
- Fix boost python building for python3
- Contributors: Fabian Poggenhans
1.0.5 (2020-09-29)
- Fix build for ROS2, gtest should no longer be installed in ROS2 mode
- Improve python nosetest info
- Update boost-python depend message
- Fix python module setup
- Packages can now have both a python module and a python api
- Add qtbase5-dev key
- Contributors: Fabian Poggenhans, Kevin Rösch, Maximilian Naumann
1.0.4 (2020-08-12)
- Deleted deprecated configuration files
- Fix cuda host compiler used for cuda 11
- Fix __init__.py template for python3
- Fix target handling for ros2
- Fix build failures on ROS1
- Fix the conan support
- Add a dependency on ros_environment to ensure ROS_VERSION is set
- Default to building shared libraries
- Add QtScript to the list of qt components
- Change license to BSD
- Remove traces of GPL-licensed libgps
- Remove unnecessary includes of cuda files
- Update tensorflow c findscript to set new tensorflow include paths
- Add cuda support for node and nodelet.
- Remove usage of ast package for evaulating package.xml conditions
- Fix crash if eval_coverage.py runs with python3
- Ensure that coverage is also generated for cpp code called from plain rostests
- Contributors: Fabian Poggenhans, Ilia Baltashov, Sven Richter
1.0.3 (2020-05-25)
- Replace deprecated platform.distro call with distro module
- Raise required CMake version to 3.0.2 to suppress warning with Noetic
- Remove boost signals component that is no longer part of boost
- Fixed c++14 test path include.
- Fix installation of python api files
- Update README.md
- Reformat with new version of cmake-format
- Add lcov as dependency again
- Fix FindBoostPython.cmake for cmake below 3.11 and python3
- Fix multiple include of MrtPCL
- Contributors: Christian-Eike Framing, Fabian Poggenhans, Johannes Beck, Johannes Janosovits, Moritz Cremer
1.0.2 (2020-03-24)
- Fix PCL findscript, disable precompiling
- added jsoncpp
- Make sure packages search for mrt_cmake_modules in their package config
- Fix resolution of packages in underlaying workspaces
- Mention rosdoc.yaml in package.xml
- Contributors: Fabian Poggenhans, Johannes Beck, Johannes Janosovits
1.0.1 (2020-03-11)
- Update maintainer
- Update generate_dependency_file to search CMAKE_PREFIX_PATH for packages instead of ROS_PACKAGE_PATH
- Update package xml to contain ROS urls and use format 3 to specify python version specific deps
- Add a rosdoc file so that ros can build the cmake api
- Contributors: Fabian Poggenhans
1.0.0 (2020-02-24)
- Initial release for ROS
- Contributors: Andre-Marcel Hellmund, Claudio Bandera, Fabian Poggenhans, Johannes Beck, Johannes Graeter, Niels Ole Salscheider, Piotr Orzechowski
Wiki Tutorials
Package Dependencies
Deps | Name |
---|---|
catkin | |
ament_cmake_core | |
ros_environment | |
gtest_vendor |
System Dependencies
Launch files
Messages
Services
Plugins
Recent questions tagged mrt_cmake_modules at Robotics Stack Exchange
mrt_cmake_modules package from mrt_cmake_modules repomrt_cmake_modules |
|
Package Summary
Tags | No category tags. |
Version | 1.0.11 |
License | BSD |
Build type | CATKIN |
Use | RECOMMENDED |
Repository Summary
Checkout URI | https://github.com/KIT-MRT/mrt_cmake_modules.git |
VCS Type | git |
VCS Version | master |
Last Updated | 2024-09-20 |
Dev Status | MAINTAINED |
CI status | No Continuous Integration |
Released | RELEASED |
Tags | No category tags. |
Contributing |
Help Wanted (0)
Good First Issues (0) Pull Requests to Review (0) |
Package Description
Additional Links
Maintainers
- Kevin Rösch
- Fabian Poggenhans
Authors
- Fabian Poggenhans
- Johannes Beck
MRT CMake Modules (Massively Reduced Time writing CMake Modules(*))
Maintainer status: maintained
- Maintainer: Kevin Rösch, Fabian Poggenhans
- Author: Johannes Beck, Claudio Bandera, Fabian Poggenhans
- License: BSD, some files MIT
- Bug / feature tracker: https://gitlab.mrt.uni-karlsruhe.de/MRT/mrt_cmake_modules/issues
- Source: git https://gitlab.mrt.uni-karlsruhe.de/MRT/mrt_cmake_modules.git (branch: master)
Imagine you whould never have to write a CMakeLists.txt file again. Never forget to install everything, no need to update it whenever you add a file, not time lost for figuring out how to call and use find_package
for your dependencies, etc.
Well, this is exactly what mrt_cmake_modules
do for you! The only thing you have to do is:
- Keep your files in a fixed structure,
- keep library and executable code in separate packages and
- make sure the package.xml actually contains all the packages you depend on.
If you don’t want to agree to this, there are ways to get this done as well. This will require you to modify our template file a bit.
On the other hand, you get a lot of things for free:
- Resolution of your dependencies in CMake
- Automatic generation of Nodes/Nodelets
- Supports C++ and Python(2/3)
- Python bindings for pybind11/boost-python
- Automated unittest detection and execution (including ROS tests)
- Automated code coverage generation
- Support for sanitizers
- Support for running clang-tidy
- Automated install of your scripts/launchfiles/executables/libraries… to the correct location
- experimental support for ROS2 and Conan builds
) Actually MRT stands for *Institut für Mess- und Regelungstechnik, the institute that develops this package.
Building
mrt_cmake_modules
is kept as leightweight as possible. It just contains a few CMake (and python) scripts. Its only dependency is catkin
and lcov
(for code coverage).
Getting started
Interested? In order to get the CMake template file, you have to run a small script: rosrun mrt_cmake_modules generate_cmakelists.py <package_name> [--ros] [--exe]
.
This will create a CMakeLists.txt file ready to be used in your project. We distinguish four different types of packages (this the --ros
and --exe
flags):
-
Library package: They have no dependency to ros (except catkin). Their goal is to either build a
lib<package>.so
, contain only headers, contain a python module, contain python bindings. Or a mixture of these. And unittests, of course. - Ros library package (–ros): Similar to the above, but can also contain message, action or configuration files
- Executable package (–exe): Provides either a number of executables, scripts or python modules for these scripts. And unittests of course.
- Node/Nodelet package (–ros –exe): Provides a number of nodes or nodelets, python nodes and launchfiles. And rostests of course.
Package structure
The best way to understand how packages have to be layed out is to have a look at the tree of an example package, and what it implies on the build.
Libraries
Here is the structure of a package called example_package
. It works out of the box with a CMakeLists.txt created with generate_cmakelists.py example_package --ros
:
.
├── CMakeLists.txt # The generated CMakeLists
├── include # The headers of this package. Available in the whole package
│ └── example_package # It is a ROS convention to keep them within include/<package_name>
│ ├── a_header.hpp
│ └── internal # Headers here are only to be used within cpp files of this package
│ └── internal_header.hpp
├── msg
│ └── a_message.msg # Messages files that will be automatically generated (only available for --ros)
├── package.xml # You should know that. Should contain at least pybind11-dev for the bindings
├── python_api # Folder for python bindings. Every file here becoms a module
│ ├── python_bindings.cpp # Will be available as "import example_package.python_bindings"
│ └── more_python_bindings.cpp # Refer to the pybind11 doc for the content of this file
├── README.md # The readme
├── src # Every cpp file in this filder will become part of libexample_package.so
│ ├── examplefile.cpp
│ ├── onemorefile.cpp
│ └── example_package # Python modules have to go to src/<package_name>
│ ├── pythonmodule.py # Will be available as "import example_package.pythonmodule"
│ └── __init__.py
└── test # Contains the unittests. Will be executed when running the test or run_tests target
├── test_example_package.cpp # Every file here will be a separate unittest executable
└── test_pyapi.py # Every py file that matches the testMatch regular expression will be executed
# using nosetest. Executables are ignored. See https://nose.readthedocs.io/
Note that everything in this structure is optional and can be left away if you don’t need it (except for the CMakeLists.txt of course).
Executables, Nodes and Nodelets
Here is the structure of a package called example_package_ros_tool
.
It works out of the box with a CMakeLists.txt created with generate_cmakelists.py example_package_ros_tool --exe --ros
:
.
├── CMakeLists.txt
├── cfg
│ └── ConfigFile.cfg # Files to be passed to dynamic_reconfigure
├── launch # Contains launch files provided by this package
│ ├── some_node.launch
│ ├── some_nodelet.launch
│ ├── some_python_node.launch
│ └── params # Contains parameter files that will be installed
│ ├── some_parameters.yaml
│ └── some_python_parameters.yaml
├── nodelet_plugins.xml # Should reference the nodelet library at lib/lib<package_name>-<nodename>-nodelet
├── package.xml # The manifest. It should reference the nodelet_plugins.xml
├── README.md
├── scripts # Executable scripts that will be installed. These can be python nodes as well
│ ├── bias_python_node.py
│ └── bias_script.sh
├── src # Every folder in here will be a node/nodelet or both
│ ├── nodename # nodename is the name of the node/nodelet
│ │ ├── somefile.cpp # Files compiled into the node and the nodelet
│ │ ├── somefile.hpp
│ │ ├── some_node.cpp # files ending with _node will end up being compiled into the node executable
│ │ └── a_nodelet.cpp # files ending whth _nodelet will end up as part of the nodelet library
│ └── example_package_ros_tool # python modules have to go to src/<package_name>.
│ ├── node_module_python.py # These files can provide the node implementation for the scripts
│ └── __init__.py
└── test # The unittests
├── test_node.cpp # Every pair of .cpp and .test files represents one rostest
├── test_node.test
├── test.cpp # A cpp file without a matching .test a normal unittest and launched without ROS
├── node_python_test.py # Same for .py and .test files with the same name. The .py file must be executable!
└── node_python_test.test
For a normal, non-ros executable the structure is similar, but simpler. Every folder in the src file will become the name of an executable, and all cpp files within it will be part of the executable.
Generating code coverage
By default, your project is compiled without code coverage information. This can be changed by setting the cmake parameter MRT_ENABLE_COVERAGE
(e.g. by configuring cmake with -DMRT_ENABLE_COVERAGE=true
).
Setting this requires a recompilation of the project.
If this is set, running the run_tests
target will run the unittests and afterwards automatically generate an html coverage report.
The location is printed in the command line. If you set MRT_ENABLE_COVERAGE=2
, it will also be opened in firefox afterwards.
Sanitizing your code
The Sanitizers Asan, Tsan and UBsan are great ways of detecting bugs at runtime.
Sadly, you cannot enable them all as once, because Tsan cannot be used together with Asan and UBsan.
You can enable them similarly to the code coverage by setting the MRT_SANITIZER
cmake variable. It has two possible values:
- checks (enables Asan and UBsan)
- check_race (enables tsan)
If one of the sanitzers discovers an error at runtime, it will be printed to cerr.
Using clang-tidy
Clang-tidy checks your code statically at compile time for patterns of unsave or wrong code. Using this feature requires clang-tidy to be installed.
You might also want to provide a .clang-tidy file within your project that enables the checks of your choice. Refere to clang-tidys documentation for details.
You can enable clang-tidy by setting the CMake variable MRT_CLANG_TIDY
.
If you set it to “check”, clang-tidy will be run at compile time alongside the normal compiler and print all issues as compiler errors. If you set it to “fix” the recommended fixes will be applied directly to your code. Careful: Not all fixes ensure that the code compiles. Also the “fix” mode of clang-tidy is not thread safe, meaning that if you compile with multiple threads, multiple clang-tidy instances might try to fix the same file at the same time.
How dependency resolution works in detail
The mrt_cmake_modules parse your manifest file (i.e. package.xml
) in order to figure out your dependencies. The following lines in the CMakeLists.txt
are responsible for this:
find_package(mrt_cmake_modules REQUIRED) # finds this module
include(UseMrtStdCompilerFlags) # sets some generally useful compiler/warning flags
include(GatherDeps) # collects your dependencies and writes them into DEPENDEND_PACKAGES
find_package(AutoDeps REQUIRED COMPONENTS ${DEPENDEND_PACKAGES}) # resolves your dependencies by calling find_package appropriately.
AutoDeps then figures out, which includes, libraries and targets are needed in order to build this package.
The result is written into MRT_INCLUDE_DIRS
, MRT_LIBRARIES
and MRT_LIBRARY_DIRS
. These variables should be passed to the cmake targets.
The magic that happens under the hood can be understood by looking at the cmake.yaml within this project. It defines, for which dependency in the package.xml which findscript has to be searched and what variables
it will set by the script if successful. These will then be appended to the MRT_*
variables.
CMake API
This package contains a lot of useful cmake functions that are automatically available in all packages using the mrt_cmake_modules as dependency, e.g. mrt_install()
, mrt_add_node_and_nodelet()
, mrt_add_library()
, etc.
The automatically generated file already makes use of them, but you can also use them in your custom CMakeLists.
See here for a full documentation.
Findscripts
This package also contains a collection of find-scripts for thirdparty dependencies that are usually not shipped with a findscript. These are required by AutoDeps.
Going further
After you have saved time writing cmake boilerplate, it is now time to also save time writing ROS boilerplate. You might want to look into the rosinterface_handler as well. It is already intergrated in the CMakeLists template.
All you have to do is write a .rosif
file, and this project will automatically handle reading parameters from the parameter server, creating subscribers and publishers and handling reconfigure callbacks for you!
Changelog for package mrt_cmake_modules
1.0.11 (2024-09-20)
- Merge pull request #38 from nobleo/fix/find-flann-cmake-module fix(FindFLANN): set(FLANN_FOUND ON) if target already defined
- Contributors: keroe
1.0.10 (2024-07-26)
- FindGeographicLib: Fix for GeographicLib 2.* and Windows Since GeographicLib version 2, the library name changed from [libGeographic.so]{.title-ref} to [libGeographicLib.so]{.title-ref}, see https://github.com/geographiclib/geographiclib/blob/5e4425da84a46eb70e59656d71b4c99732a570ec/NEWS#L208 . To ensure that GeographicLib 2.* is found correcty, I think we should add also [GeographicLib]{.title-ref} to the names used by [find_library]{.title-ref}. Furthermore, on Windows the import library is called [GeographicLib-i.lib]{.title-ref} (see https://github.com/geographiclib/geographiclib/blob/v2.3/src/CMakeLists.txt#L119), so to find the library correctly on Windows we also look for GeographicLib-i .
- add ortools
- Revert "mrt_add_library now adds a compilation tests for all headers used by the library" This reverts commit b05cac0200ce6b8de8e8a18789dbd58cd9d8d1eb.
- Merge branch 'master' into HEAD
- Changes how the check for formatting is done. Now the CI job uses the --check flag provided by cmake_format instead of the [git diff]{.title-ref} check, because git caused some problems in this repo.
- format
- mrt_add_library now adds a compilation tests for all headers used by the library
- Add ZeroMQ
- Add zxing-cpp to cmake.yaml.
- hard coded ignore files which start with "mocs_compilation and delete the corresponding gcda file, because otherwise our current coverage pipeline fails.
- Contributors: Fabian Poggenhans, Jan-Hendrik Pauls, Johannes Beck, Kevin Rösch, Mrt Builder, Yinzhe Shen
1.0.9 (2021-11-26)
- Set python version
- Set PYTHON_EXECUTABLE for rolling
- Add find script and cmake.yml entry for proj.
- Update FLANN find script to work with newer versions.
- add boost iostreams component
- Removed debug message.
- Fix find boost python for cmake 3.20.
- add xerces and curl to camke.yaml
- Fix warnings in CUDA code.
- Remove cmake 3.20-only syntax
- Headers from dependencies are no longer marked as system, except from overlayed workspaces
- Set the ccache base dir as environment variable of the compiler command
- add pangolin
- Fix formatting of test failures on python3
- Fix recovering from sanitizer issues by making sure the flag is set only once resolves MRT/draft/simulation_adenauerring#34
- fix action build
- Use mrt_cgal again (brings a newer version than ubuntu)
- Adding or-tools to cmake.yaml.
- Sanitizers: enable recovering form nullptr issues even in no_recover mode this fixes otherwise unfixable issues e.g. in boost::serialization using this
- Update/remove old maintainer emails
- Improve evaluation of conditions in package.xml in order to make it more compliant with REP149
- Increase character limits for conditions specified package.xml This is necessary so that conditions that are based on ROS_DISTRO can be specified
- Add cmake entry for libnlopt-cpp-dev, new for focal
- Fix python script installation (shebang replacement)
- Add mrt_casadi to cmake.yaml
- Add mrt_hpipm to cmake.yaml
- Add mrt_blasfeo to cmake.yaml
- Add a small Readme pointing to cmake-format
- change name to match internal name
- add mrt-osqp-eigen
- add osqp
- Fix aravis find script.
- Switch to use aravis 0.8.
- Contributors: Fabian Poggenhans, Ilia Baltashov, Johannes Beck, Kevin Rösch, Maximilian Naumann, Piotr Orzechowski, Bernd Kröper, wep21
1.0.8 (2020-09-30)
- Fix finding boost python on versions with old cmake but new boost
- Contributors: Fabian Poggenhans
1.0.7 (2020-09-30)
- Fix versioning of sofiles
- Ensure unittests use the right gtest include dir
- Contributors: Fabian Poggenhans
1.0.6 (2020-09-30)
- Fix boost python building for python3
- Contributors: Fabian Poggenhans
1.0.5 (2020-09-29)
- Fix build for ROS2, gtest should no longer be installed in ROS2 mode
- Improve python nosetest info
- Update boost-python depend message
- Fix python module setup
- Packages can now have both a python module and a python api
- Add qtbase5-dev key
- Contributors: Fabian Poggenhans, Kevin Rösch, Maximilian Naumann
1.0.4 (2020-08-12)
- Deleted deprecated configuration files
- Fix cuda host compiler used for cuda 11
- Fix __init__.py template for python3
- Fix target handling for ros2
- Fix build failures on ROS1
- Fix the conan support
- Add a dependency on ros_environment to ensure ROS_VERSION is set
- Default to building shared libraries
- Add QtScript to the list of qt components
- Change license to BSD
- Remove traces of GPL-licensed libgps
- Remove unnecessary includes of cuda files
- Update tensorflow c findscript to set new tensorflow include paths
- Add cuda support for node and nodelet.
- Remove usage of ast package for evaulating package.xml conditions
- Fix crash if eval_coverage.py runs with python3
- Ensure that coverage is also generated for cpp code called from plain rostests
- Contributors: Fabian Poggenhans, Ilia Baltashov, Sven Richter
1.0.3 (2020-05-25)
- Replace deprecated platform.distro call with distro module
- Raise required CMake version to 3.0.2 to suppress warning with Noetic
- Remove boost signals component that is no longer part of boost
- Fixed c++14 test path include.
- Fix installation of python api files
- Update README.md
- Reformat with new version of cmake-format
- Add lcov as dependency again
- Fix FindBoostPython.cmake for cmake below 3.11 and python3
- Fix multiple include of MrtPCL
- Contributors: Christian-Eike Framing, Fabian Poggenhans, Johannes Beck, Johannes Janosovits, Moritz Cremer
1.0.2 (2020-03-24)
- Fix PCL findscript, disable precompiling
- added jsoncpp
- Make sure packages search for mrt_cmake_modules in their package config
- Fix resolution of packages in underlaying workspaces
- Mention rosdoc.yaml in package.xml
- Contributors: Fabian Poggenhans, Johannes Beck, Johannes Janosovits
1.0.1 (2020-03-11)
- Update maintainer
- Update generate_dependency_file to search CMAKE_PREFIX_PATH for packages instead of ROS_PACKAGE_PATH
- Update package xml to contain ROS urls and use format 3 to specify python version specific deps
- Add a rosdoc file so that ros can build the cmake api
- Contributors: Fabian Poggenhans
1.0.0 (2020-02-24)
- Initial release for ROS
- Contributors: Andre-Marcel Hellmund, Claudio Bandera, Fabian Poggenhans, Johannes Beck, Johannes Graeter, Niels Ole Salscheider, Piotr Orzechowski
Wiki Tutorials
Package Dependencies
Deps | Name |
---|---|
catkin | |
ament_cmake_core | |
ros_environment | |
gtest_vendor |
System Dependencies
Launch files
Messages
Services
Plugins
Recent questions tagged mrt_cmake_modules at Robotics Stack Exchange
mrt_cmake_modules package from mrt_cmake_modules repomrt_cmake_modules |
|
Package Summary
Tags | No category tags. |
Version | 1.0.11 |
License | BSD |
Build type | CATKIN |
Use | RECOMMENDED |
Repository Summary
Checkout URI | https://github.com/KIT-MRT/mrt_cmake_modules.git |
VCS Type | git |
VCS Version | master |
Last Updated | 2024-09-20 |
Dev Status | MAINTAINED |
CI status | No Continuous Integration |
Released | RELEASED |
Tags | No category tags. |
Contributing |
Help Wanted (0)
Good First Issues (0) Pull Requests to Review (0) |
Package Description
Additional Links
Maintainers
- Kevin Rösch
- Fabian Poggenhans
Authors
- Fabian Poggenhans
- Johannes Beck
MRT CMake Modules (Massively Reduced Time writing CMake Modules(*))
Maintainer status: maintained
- Maintainer: Kevin Rösch, Fabian Poggenhans
- Author: Johannes Beck, Claudio Bandera, Fabian Poggenhans
- License: BSD, some files MIT
- Bug / feature tracker: https://gitlab.mrt.uni-karlsruhe.de/MRT/mrt_cmake_modules/issues
- Source: git https://gitlab.mrt.uni-karlsruhe.de/MRT/mrt_cmake_modules.git (branch: master)
Imagine you whould never have to write a CMakeLists.txt file again. Never forget to install everything, no need to update it whenever you add a file, not time lost for figuring out how to call and use find_package
for your dependencies, etc.
Well, this is exactly what mrt_cmake_modules
do for you! The only thing you have to do is:
- Keep your files in a fixed structure,
- keep library and executable code in separate packages and
- make sure the package.xml actually contains all the packages you depend on.
If you don’t want to agree to this, there are ways to get this done as well. This will require you to modify our template file a bit.
On the other hand, you get a lot of things for free:
- Resolution of your dependencies in CMake
- Automatic generation of Nodes/Nodelets
- Supports C++ and Python(2/3)
- Python bindings for pybind11/boost-python
- Automated unittest detection and execution (including ROS tests)
- Automated code coverage generation
- Support for sanitizers
- Support for running clang-tidy
- Automated install of your scripts/launchfiles/executables/libraries… to the correct location
- experimental support for ROS2 and Conan builds
) Actually MRT stands for *Institut für Mess- und Regelungstechnik, the institute that develops this package.
Building
mrt_cmake_modules
is kept as leightweight as possible. It just contains a few CMake (and python) scripts. Its only dependency is catkin
and lcov
(for code coverage).
Getting started
Interested? In order to get the CMake template file, you have to run a small script: rosrun mrt_cmake_modules generate_cmakelists.py <package_name> [--ros] [--exe]
.
This will create a CMakeLists.txt file ready to be used in your project. We distinguish four different types of packages (this the --ros
and --exe
flags):
-
Library package: They have no dependency to ros (except catkin). Their goal is to either build a
lib<package>.so
, contain only headers, contain a python module, contain python bindings. Or a mixture of these. And unittests, of course. - Ros library package (–ros): Similar to the above, but can also contain message, action or configuration files
- Executable package (–exe): Provides either a number of executables, scripts or python modules for these scripts. And unittests of course.
- Node/Nodelet package (–ros –exe): Provides a number of nodes or nodelets, python nodes and launchfiles. And rostests of course.
Package structure
The best way to understand how packages have to be layed out is to have a look at the tree of an example package, and what it implies on the build.
Libraries
Here is the structure of a package called example_package
. It works out of the box with a CMakeLists.txt created with generate_cmakelists.py example_package --ros
:
.
├── CMakeLists.txt # The generated CMakeLists
├── include # The headers of this package. Available in the whole package
│ └── example_package # It is a ROS convention to keep them within include/<package_name>
│ ├── a_header.hpp
│ └── internal # Headers here are only to be used within cpp files of this package
│ └── internal_header.hpp
├── msg
│ └── a_message.msg # Messages files that will be automatically generated (only available for --ros)
├── package.xml # You should know that. Should contain at least pybind11-dev for the bindings
├── python_api # Folder for python bindings. Every file here becoms a module
│ ├── python_bindings.cpp # Will be available as "import example_package.python_bindings"
│ └── more_python_bindings.cpp # Refer to the pybind11 doc for the content of this file
├── README.md # The readme
├── src # Every cpp file in this filder will become part of libexample_package.so
│ ├── examplefile.cpp
│ ├── onemorefile.cpp
│ └── example_package # Python modules have to go to src/<package_name>
│ ├── pythonmodule.py # Will be available as "import example_package.pythonmodule"
│ └── __init__.py
└── test # Contains the unittests. Will be executed when running the test or run_tests target
├── test_example_package.cpp # Every file here will be a separate unittest executable
└── test_pyapi.py # Every py file that matches the testMatch regular expression will be executed
# using nosetest. Executables are ignored. See https://nose.readthedocs.io/
Note that everything in this structure is optional and can be left away if you don’t need it (except for the CMakeLists.txt of course).
Executables, Nodes and Nodelets
Here is the structure of a package called example_package_ros_tool
.
It works out of the box with a CMakeLists.txt created with generate_cmakelists.py example_package_ros_tool --exe --ros
:
.
├── CMakeLists.txt
├── cfg
│ └── ConfigFile.cfg # Files to be passed to dynamic_reconfigure
├── launch # Contains launch files provided by this package
│ ├── some_node.launch
│ ├── some_nodelet.launch
│ ├── some_python_node.launch
│ └── params # Contains parameter files that will be installed
│ ├── some_parameters.yaml
│ └── some_python_parameters.yaml
├── nodelet_plugins.xml # Should reference the nodelet library at lib/lib<package_name>-<nodename>-nodelet
├── package.xml # The manifest. It should reference the nodelet_plugins.xml
├── README.md
├── scripts # Executable scripts that will be installed. These can be python nodes as well
│ ├── bias_python_node.py
│ └── bias_script.sh
├── src # Every folder in here will be a node/nodelet or both
│ ├── nodename # nodename is the name of the node/nodelet
│ │ ├── somefile.cpp # Files compiled into the node and the nodelet
│ │ ├── somefile.hpp
│ │ ├── some_node.cpp # files ending with _node will end up being compiled into the node executable
│ │ └── a_nodelet.cpp # files ending whth _nodelet will end up as part of the nodelet library
│ └── example_package_ros_tool # python modules have to go to src/<package_name>.
│ ├── node_module_python.py # These files can provide the node implementation for the scripts
│ └── __init__.py
└── test # The unittests
├── test_node.cpp # Every pair of .cpp and .test files represents one rostest
├── test_node.test
├── test.cpp # A cpp file without a matching .test a normal unittest and launched without ROS
├── node_python_test.py # Same for .py and .test files with the same name. The .py file must be executable!
└── node_python_test.test
For a normal, non-ros executable the structure is similar, but simpler. Every folder in the src file will become the name of an executable, and all cpp files within it will be part of the executable.
Generating code coverage
By default, your project is compiled without code coverage information. This can be changed by setting the cmake parameter MRT_ENABLE_COVERAGE
(e.g. by configuring cmake with -DMRT_ENABLE_COVERAGE=true
).
Setting this requires a recompilation of the project.
If this is set, running the run_tests
target will run the unittests and afterwards automatically generate an html coverage report.
The location is printed in the command line. If you set MRT_ENABLE_COVERAGE=2
, it will also be opened in firefox afterwards.
Sanitizing your code
The Sanitizers Asan, Tsan and UBsan are great ways of detecting bugs at runtime.
Sadly, you cannot enable them all as once, because Tsan cannot be used together with Asan and UBsan.
You can enable them similarly to the code coverage by setting the MRT_SANITIZER
cmake variable. It has two possible values:
- checks (enables Asan and UBsan)
- check_race (enables tsan)
If one of the sanitzers discovers an error at runtime, it will be printed to cerr.
Using clang-tidy
Clang-tidy checks your code statically at compile time for patterns of unsave or wrong code. Using this feature requires clang-tidy to be installed.
You might also want to provide a .clang-tidy file within your project that enables the checks of your choice. Refere to clang-tidys documentation for details.
You can enable clang-tidy by setting the CMake variable MRT_CLANG_TIDY
.
If you set it to “check”, clang-tidy will be run at compile time alongside the normal compiler and print all issues as compiler errors. If you set it to “fix” the recommended fixes will be applied directly to your code. Careful: Not all fixes ensure that the code compiles. Also the “fix” mode of clang-tidy is not thread safe, meaning that if you compile with multiple threads, multiple clang-tidy instances might try to fix the same file at the same time.
How dependency resolution works in detail
The mrt_cmake_modules parse your manifest file (i.e. package.xml
) in order to figure out your dependencies. The following lines in the CMakeLists.txt
are responsible for this:
find_package(mrt_cmake_modules REQUIRED) # finds this module
include(UseMrtStdCompilerFlags) # sets some generally useful compiler/warning flags
include(GatherDeps) # collects your dependencies and writes them into DEPENDEND_PACKAGES
find_package(AutoDeps REQUIRED COMPONENTS ${DEPENDEND_PACKAGES}) # resolves your dependencies by calling find_package appropriately.
AutoDeps then figures out, which includes, libraries and targets are needed in order to build this package.
The result is written into MRT_INCLUDE_DIRS
, MRT_LIBRARIES
and MRT_LIBRARY_DIRS
. These variables should be passed to the cmake targets.
The magic that happens under the hood can be understood by looking at the cmake.yaml within this project. It defines, for which dependency in the package.xml which findscript has to be searched and what variables
it will set by the script if successful. These will then be appended to the MRT_*
variables.
CMake API
This package contains a lot of useful cmake functions that are automatically available in all packages using the mrt_cmake_modules as dependency, e.g. mrt_install()
, mrt_add_node_and_nodelet()
, mrt_add_library()
, etc.
The automatically generated file already makes use of them, but you can also use them in your custom CMakeLists.
See here for a full documentation.
Findscripts
This package also contains a collection of find-scripts for thirdparty dependencies that are usually not shipped with a findscript. These are required by AutoDeps.
Going further
After you have saved time writing cmake boilerplate, it is now time to also save time writing ROS boilerplate. You might want to look into the rosinterface_handler as well. It is already intergrated in the CMakeLists template.
All you have to do is write a .rosif
file, and this project will automatically handle reading parameters from the parameter server, creating subscribers and publishers and handling reconfigure callbacks for you!
Changelog for package mrt_cmake_modules
1.0.11 (2024-09-20)
- Merge pull request #38 from nobleo/fix/find-flann-cmake-module fix(FindFLANN): set(FLANN_FOUND ON) if target already defined
- Contributors: keroe
1.0.10 (2024-07-26)
- FindGeographicLib: Fix for GeographicLib 2.* and Windows Since GeographicLib version 2, the library name changed from [libGeographic.so]{.title-ref} to [libGeographicLib.so]{.title-ref}, see https://github.com/geographiclib/geographiclib/blob/5e4425da84a46eb70e59656d71b4c99732a570ec/NEWS#L208 . To ensure that GeographicLib 2.* is found correcty, I think we should add also [GeographicLib]{.title-ref} to the names used by [find_library]{.title-ref}. Furthermore, on Windows the import library is called [GeographicLib-i.lib]{.title-ref} (see https://github.com/geographiclib/geographiclib/blob/v2.3/src/CMakeLists.txt#L119), so to find the library correctly on Windows we also look for GeographicLib-i .
- add ortools
- Revert "mrt_add_library now adds a compilation tests for all headers used by the library" This reverts commit b05cac0200ce6b8de8e8a18789dbd58cd9d8d1eb.
- Merge branch 'master' into HEAD
- Changes how the check for formatting is done. Now the CI job uses the --check flag provided by cmake_format instead of the [git diff]{.title-ref} check, because git caused some problems in this repo.
- format
- mrt_add_library now adds a compilation tests for all headers used by the library
- Add ZeroMQ
- Add zxing-cpp to cmake.yaml.
- hard coded ignore files which start with "mocs_compilation and delete the corresponding gcda file, because otherwise our current coverage pipeline fails.
- Contributors: Fabian Poggenhans, Jan-Hendrik Pauls, Johannes Beck, Kevin Rösch, Mrt Builder, Yinzhe Shen
1.0.9 (2021-11-26)
- Set python version
- Set PYTHON_EXECUTABLE for rolling
- Add find script and cmake.yml entry for proj.
- Update FLANN find script to work with newer versions.
- add boost iostreams component
- Removed debug message.
- Fix find boost python for cmake 3.20.
- add xerces and curl to camke.yaml
- Fix warnings in CUDA code.
- Remove cmake 3.20-only syntax
- Headers from dependencies are no longer marked as system, except from overlayed workspaces
- Set the ccache base dir as environment variable of the compiler command
- add pangolin
- Fix formatting of test failures on python3
- Fix recovering from sanitizer issues by making sure the flag is set only once resolves MRT/draft/simulation_adenauerring#34
- fix action build
- Use mrt_cgal again (brings a newer version than ubuntu)
- Adding or-tools to cmake.yaml.
- Sanitizers: enable recovering form nullptr issues even in no_recover mode this fixes otherwise unfixable issues e.g. in boost::serialization using this
- Update/remove old maintainer emails
- Improve evaluation of conditions in package.xml in order to make it more compliant with REP149
- Increase character limits for conditions specified package.xml This is necessary so that conditions that are based on ROS_DISTRO can be specified
- Add cmake entry for libnlopt-cpp-dev, new for focal
- Fix python script installation (shebang replacement)
- Add mrt_casadi to cmake.yaml
- Add mrt_hpipm to cmake.yaml
- Add mrt_blasfeo to cmake.yaml
- Add a small Readme pointing to cmake-format
- change name to match internal name
- add mrt-osqp-eigen
- add osqp
- Fix aravis find script.
- Switch to use aravis 0.8.
- Contributors: Fabian Poggenhans, Ilia Baltashov, Johannes Beck, Kevin Rösch, Maximilian Naumann, Piotr Orzechowski, Bernd Kröper, wep21
1.0.8 (2020-09-30)
- Fix finding boost python on versions with old cmake but new boost
- Contributors: Fabian Poggenhans
1.0.7 (2020-09-30)
- Fix versioning of sofiles
- Ensure unittests use the right gtest include dir
- Contributors: Fabian Poggenhans
1.0.6 (2020-09-30)
- Fix boost python building for python3
- Contributors: Fabian Poggenhans
1.0.5 (2020-09-29)
- Fix build for ROS2, gtest should no longer be installed in ROS2 mode
- Improve python nosetest info
- Update boost-python depend message
- Fix python module setup
- Packages can now have both a python module and a python api
- Add qtbase5-dev key
- Contributors: Fabian Poggenhans, Kevin Rösch, Maximilian Naumann
1.0.4 (2020-08-12)
- Deleted deprecated configuration files
- Fix cuda host compiler used for cuda 11
- Fix __init__.py template for python3
- Fix target handling for ros2
- Fix build failures on ROS1
- Fix the conan support
- Add a dependency on ros_environment to ensure ROS_VERSION is set
- Default to building shared libraries
- Add QtScript to the list of qt components
- Change license to BSD
- Remove traces of GPL-licensed libgps
- Remove unnecessary includes of cuda files
- Update tensorflow c findscript to set new tensorflow include paths
- Add cuda support for node and nodelet.
- Remove usage of ast package for evaulating package.xml conditions
- Fix crash if eval_coverage.py runs with python3
- Ensure that coverage is also generated for cpp code called from plain rostests
- Contributors: Fabian Poggenhans, Ilia Baltashov, Sven Richter
1.0.3 (2020-05-25)
- Replace deprecated platform.distro call with distro module
- Raise required CMake version to 3.0.2 to suppress warning with Noetic
- Remove boost signals component that is no longer part of boost
- Fixed c++14 test path include.
- Fix installation of python api files
- Update README.md
- Reformat with new version of cmake-format
- Add lcov as dependency again
- Fix FindBoostPython.cmake for cmake below 3.11 and python3
- Fix multiple include of MrtPCL
- Contributors: Christian-Eike Framing, Fabian Poggenhans, Johannes Beck, Johannes Janosovits, Moritz Cremer
1.0.2 (2020-03-24)
- Fix PCL findscript, disable precompiling
- added jsoncpp
- Make sure packages search for mrt_cmake_modules in their package config
- Fix resolution of packages in underlaying workspaces
- Mention rosdoc.yaml in package.xml
- Contributors: Fabian Poggenhans, Johannes Beck, Johannes Janosovits
1.0.1 (2020-03-11)
- Update maintainer
- Update generate_dependency_file to search CMAKE_PREFIX_PATH for packages instead of ROS_PACKAGE_PATH
- Update package xml to contain ROS urls and use format 3 to specify python version specific deps
- Add a rosdoc file so that ros can build the cmake api
- Contributors: Fabian Poggenhans
1.0.0 (2020-02-24)
- Initial release for ROS
- Contributors: Andre-Marcel Hellmund, Claudio Bandera, Fabian Poggenhans, Johannes Beck, Johannes Graeter, Niels Ole Salscheider, Piotr Orzechowski
Wiki Tutorials
Package Dependencies
Deps | Name |
---|---|
catkin | |
ament_cmake_core | |
ros_environment | |
gtest_vendor |
System Dependencies
Launch files
Messages
Services
Plugins
Recent questions tagged mrt_cmake_modules at Robotics Stack Exchange
mrt_cmake_modules package from mrt_cmake_modules repomrt_cmake_modules |
|
Package Summary
Tags | No category tags. |
Version | 1.0.11 |
License | BSD |
Build type | CATKIN |
Use | RECOMMENDED |
Repository Summary
Checkout URI | https://github.com/KIT-MRT/mrt_cmake_modules.git |
VCS Type | git |
VCS Version | master |
Last Updated | 2024-09-20 |
Dev Status | MAINTAINED |
CI status | No Continuous Integration |
Released | RELEASED |
Tags | No category tags. |
Contributing |
Help Wanted (0)
Good First Issues (0) Pull Requests to Review (0) |
Package Description
Additional Links
Maintainers
- Kevin Rösch
- Fabian Poggenhans
Authors
- Fabian Poggenhans
- Johannes Beck
MRT CMake Modules (Massively Reduced Time writing CMake Modules(*))
Maintainer status: maintained
- Maintainer: Kevin Rösch, Fabian Poggenhans
- Author: Johannes Beck, Claudio Bandera, Fabian Poggenhans
- License: BSD, some files MIT
- Bug / feature tracker: https://gitlab.mrt.uni-karlsruhe.de/MRT/mrt_cmake_modules/issues
- Source: git https://gitlab.mrt.uni-karlsruhe.de/MRT/mrt_cmake_modules.git (branch: master)
Imagine you whould never have to write a CMakeLists.txt file again. Never forget to install everything, no need to update it whenever you add a file, not time lost for figuring out how to call and use find_package
for your dependencies, etc.
Well, this is exactly what mrt_cmake_modules
do for you! The only thing you have to do is:
- Keep your files in a fixed structure,
- keep library and executable code in separate packages and
- make sure the package.xml actually contains all the packages you depend on.
If you don’t want to agree to this, there are ways to get this done as well. This will require you to modify our template file a bit.
On the other hand, you get a lot of things for free:
- Resolution of your dependencies in CMake
- Automatic generation of Nodes/Nodelets
- Supports C++ and Python(2/3)
- Python bindings for pybind11/boost-python
- Automated unittest detection and execution (including ROS tests)
- Automated code coverage generation
- Support for sanitizers
- Support for running clang-tidy
- Automated install of your scripts/launchfiles/executables/libraries… to the correct location
- experimental support for ROS2 and Conan builds
) Actually MRT stands for *Institut für Mess- und Regelungstechnik, the institute that develops this package.
Building
mrt_cmake_modules
is kept as leightweight as possible. It just contains a few CMake (and python) scripts. Its only dependency is catkin
and lcov
(for code coverage).
Getting started
Interested? In order to get the CMake template file, you have to run a small script: rosrun mrt_cmake_modules generate_cmakelists.py <package_name> [--ros] [--exe]
.
This will create a CMakeLists.txt file ready to be used in your project. We distinguish four different types of packages (this the --ros
and --exe
flags):
-
Library package: They have no dependency to ros (except catkin). Their goal is to either build a
lib<package>.so
, contain only headers, contain a python module, contain python bindings. Or a mixture of these. And unittests, of course. - Ros library package (–ros): Similar to the above, but can also contain message, action or configuration files
- Executable package (–exe): Provides either a number of executables, scripts or python modules for these scripts. And unittests of course.
- Node/Nodelet package (–ros –exe): Provides a number of nodes or nodelets, python nodes and launchfiles. And rostests of course.
Package structure
The best way to understand how packages have to be layed out is to have a look at the tree of an example package, and what it implies on the build.
Libraries
Here is the structure of a package called example_package
. It works out of the box with a CMakeLists.txt created with generate_cmakelists.py example_package --ros
:
.
├── CMakeLists.txt # The generated CMakeLists
├── include # The headers of this package. Available in the whole package
│ └── example_package # It is a ROS convention to keep them within include/<package_name>
│ ├── a_header.hpp
│ └── internal # Headers here are only to be used within cpp files of this package
│ └── internal_header.hpp
├── msg
│ └── a_message.msg # Messages files that will be automatically generated (only available for --ros)
├── package.xml # You should know that. Should contain at least pybind11-dev for the bindings
├── python_api # Folder for python bindings. Every file here becoms a module
│ ├── python_bindings.cpp # Will be available as "import example_package.python_bindings"
│ └── more_python_bindings.cpp # Refer to the pybind11 doc for the content of this file
├── README.md # The readme
├── src # Every cpp file in this filder will become part of libexample_package.so
│ ├── examplefile.cpp
│ ├── onemorefile.cpp
│ └── example_package # Python modules have to go to src/<package_name>
│ ├── pythonmodule.py # Will be available as "import example_package.pythonmodule"
│ └── __init__.py
└── test # Contains the unittests. Will be executed when running the test or run_tests target
├── test_example_package.cpp # Every file here will be a separate unittest executable
└── test_pyapi.py # Every py file that matches the testMatch regular expression will be executed
# using nosetest. Executables are ignored. See https://nose.readthedocs.io/
Note that everything in this structure is optional and can be left away if you don’t need it (except for the CMakeLists.txt of course).
Executables, Nodes and Nodelets
Here is the structure of a package called example_package_ros_tool
.
It works out of the box with a CMakeLists.txt created with generate_cmakelists.py example_package_ros_tool --exe --ros
:
.
├── CMakeLists.txt
├── cfg
│ └── ConfigFile.cfg # Files to be passed to dynamic_reconfigure
├── launch # Contains launch files provided by this package
│ ├── some_node.launch
│ ├── some_nodelet.launch
│ ├── some_python_node.launch
│ └── params # Contains parameter files that will be installed
│ ├── some_parameters.yaml
│ └── some_python_parameters.yaml
├── nodelet_plugins.xml # Should reference the nodelet library at lib/lib<package_name>-<nodename>-nodelet
├── package.xml # The manifest. It should reference the nodelet_plugins.xml
├── README.md
├── scripts # Executable scripts that will be installed. These can be python nodes as well
│ ├── bias_python_node.py
│ └── bias_script.sh
├── src # Every folder in here will be a node/nodelet or both
│ ├── nodename # nodename is the name of the node/nodelet
│ │ ├── somefile.cpp # Files compiled into the node and the nodelet
│ │ ├── somefile.hpp
│ │ ├── some_node.cpp # files ending with _node will end up being compiled into the node executable
│ │ └── a_nodelet.cpp # files ending whth _nodelet will end up as part of the nodelet library
│ └── example_package_ros_tool # python modules have to go to src/<package_name>.
│ ├── node_module_python.py # These files can provide the node implementation for the scripts
│ └── __init__.py
└── test # The unittests
├── test_node.cpp # Every pair of .cpp and .test files represents one rostest
├── test_node.test
├── test.cpp # A cpp file without a matching .test a normal unittest and launched without ROS
├── node_python_test.py # Same for .py and .test files with the same name. The .py file must be executable!
└── node_python_test.test
For a normal, non-ros executable the structure is similar, but simpler. Every folder in the src file will become the name of an executable, and all cpp files within it will be part of the executable.
Generating code coverage
By default, your project is compiled without code coverage information. This can be changed by setting the cmake parameter MRT_ENABLE_COVERAGE
(e.g. by configuring cmake with -DMRT_ENABLE_COVERAGE=true
).
Setting this requires a recompilation of the project.
If this is set, running the run_tests
target will run the unittests and afterwards automatically generate an html coverage report.
The location is printed in the command line. If you set MRT_ENABLE_COVERAGE=2
, it will also be opened in firefox afterwards.
Sanitizing your code
The Sanitizers Asan, Tsan and UBsan are great ways of detecting bugs at runtime.
Sadly, you cannot enable them all as once, because Tsan cannot be used together with Asan and UBsan.
You can enable them similarly to the code coverage by setting the MRT_SANITIZER
cmake variable. It has two possible values:
- checks (enables Asan and UBsan)
- check_race (enables tsan)
If one of the sanitzers discovers an error at runtime, it will be printed to cerr.
Using clang-tidy
Clang-tidy checks your code statically at compile time for patterns of unsave or wrong code. Using this feature requires clang-tidy to be installed.
You might also want to provide a .clang-tidy file within your project that enables the checks of your choice. Refere to clang-tidys documentation for details.
You can enable clang-tidy by setting the CMake variable MRT_CLANG_TIDY
.
If you set it to “check”, clang-tidy will be run at compile time alongside the normal compiler and print all issues as compiler errors. If you set it to “fix” the recommended fixes will be applied directly to your code. Careful: Not all fixes ensure that the code compiles. Also the “fix” mode of clang-tidy is not thread safe, meaning that if you compile with multiple threads, multiple clang-tidy instances might try to fix the same file at the same time.
How dependency resolution works in detail
The mrt_cmake_modules parse your manifest file (i.e. package.xml
) in order to figure out your dependencies. The following lines in the CMakeLists.txt
are responsible for this:
find_package(mrt_cmake_modules REQUIRED) # finds this module
include(UseMrtStdCompilerFlags) # sets some generally useful compiler/warning flags
include(GatherDeps) # collects your dependencies and writes them into DEPENDEND_PACKAGES
find_package(AutoDeps REQUIRED COMPONENTS ${DEPENDEND_PACKAGES}) # resolves your dependencies by calling find_package appropriately.
AutoDeps then figures out, which includes, libraries and targets are needed in order to build this package.
The result is written into MRT_INCLUDE_DIRS
, MRT_LIBRARIES
and MRT_LIBRARY_DIRS
. These variables should be passed to the cmake targets.
The magic that happens under the hood can be understood by looking at the cmake.yaml within this project. It defines, for which dependency in the package.xml which findscript has to be searched and what variables
it will set by the script if successful. These will then be appended to the MRT_*
variables.
CMake API
This package contains a lot of useful cmake functions that are automatically available in all packages using the mrt_cmake_modules as dependency, e.g. mrt_install()
, mrt_add_node_and_nodelet()
, mrt_add_library()
, etc.
The automatically generated file already makes use of them, but you can also use them in your custom CMakeLists.
See here for a full documentation.
Findscripts
This package also contains a collection of find-scripts for thirdparty dependencies that are usually not shipped with a findscript. These are required by AutoDeps.
Going further
After you have saved time writing cmake boilerplate, it is now time to also save time writing ROS boilerplate. You might want to look into the rosinterface_handler as well. It is already intergrated in the CMakeLists template.
All you have to do is write a .rosif
file, and this project will automatically handle reading parameters from the parameter server, creating subscribers and publishers and handling reconfigure callbacks for you!
Changelog for package mrt_cmake_modules
1.0.11 (2024-09-20)
- Merge pull request #38 from nobleo/fix/find-flann-cmake-module fix(FindFLANN): set(FLANN_FOUND ON) if target already defined
- Contributors: keroe
1.0.10 (2024-07-26)
- FindGeographicLib: Fix for GeographicLib 2.* and Windows Since GeographicLib version 2, the library name changed from [libGeographic.so]{.title-ref} to [libGeographicLib.so]{.title-ref}, see https://github.com/geographiclib/geographiclib/blob/5e4425da84a46eb70e59656d71b4c99732a570ec/NEWS#L208 . To ensure that GeographicLib 2.* is found correcty, I think we should add also [GeographicLib]{.title-ref} to the names used by [find_library]{.title-ref}. Furthermore, on Windows the import library is called [GeographicLib-i.lib]{.title-ref} (see https://github.com/geographiclib/geographiclib/blob/v2.3/src/CMakeLists.txt#L119), so to find the library correctly on Windows we also look for GeographicLib-i .
- add ortools
- Revert "mrt_add_library now adds a compilation tests for all headers used by the library" This reverts commit b05cac0200ce6b8de8e8a18789dbd58cd9d8d1eb.
- Merge branch 'master' into HEAD
- Changes how the check for formatting is done. Now the CI job uses the --check flag provided by cmake_format instead of the [git diff]{.title-ref} check, because git caused some problems in this repo.
- format
- mrt_add_library now adds a compilation tests for all headers used by the library
- Add ZeroMQ
- Add zxing-cpp to cmake.yaml.
- hard coded ignore files which start with "mocs_compilation and delete the corresponding gcda file, because otherwise our current coverage pipeline fails.
- Contributors: Fabian Poggenhans, Jan-Hendrik Pauls, Johannes Beck, Kevin Rösch, Mrt Builder, Yinzhe Shen
1.0.9 (2021-11-26)
- Set python version
- Set PYTHON_EXECUTABLE for rolling
- Add find script and cmake.yml entry for proj.
- Update FLANN find script to work with newer versions.
- add boost iostreams component
- Removed debug message.
- Fix find boost python for cmake 3.20.
- add xerces and curl to camke.yaml
- Fix warnings in CUDA code.
- Remove cmake 3.20-only syntax
- Headers from dependencies are no longer marked as system, except from overlayed workspaces
- Set the ccache base dir as environment variable of the compiler command
- add pangolin
- Fix formatting of test failures on python3
- Fix recovering from sanitizer issues by making sure the flag is set only once resolves MRT/draft/simulation_adenauerring#34
- fix action build
- Use mrt_cgal again (brings a newer version than ubuntu)
- Adding or-tools to cmake.yaml.
- Sanitizers: enable recovering form nullptr issues even in no_recover mode this fixes otherwise unfixable issues e.g. in boost::serialization using this
- Update/remove old maintainer emails
- Improve evaluation of conditions in package.xml in order to make it more compliant with REP149
- Increase character limits for conditions specified package.xml This is necessary so that conditions that are based on ROS_DISTRO can be specified
- Add cmake entry for libnlopt-cpp-dev, new for focal
- Fix python script installation (shebang replacement)
- Add mrt_casadi to cmake.yaml
- Add mrt_hpipm to cmake.yaml
- Add mrt_blasfeo to cmake.yaml
- Add a small Readme pointing to cmake-format
- change name to match internal name
- add mrt-osqp-eigen
- add osqp
- Fix aravis find script.
- Switch to use aravis 0.8.
- Contributors: Fabian Poggenhans, Ilia Baltashov, Johannes Beck, Kevin Rösch, Maximilian Naumann, Piotr Orzechowski, Bernd Kröper, wep21
1.0.8 (2020-09-30)
- Fix finding boost python on versions with old cmake but new boost
- Contributors: Fabian Poggenhans
1.0.7 (2020-09-30)
- Fix versioning of sofiles
- Ensure unittests use the right gtest include dir
- Contributors: Fabian Poggenhans
1.0.6 (2020-09-30)
- Fix boost python building for python3
- Contributors: Fabian Poggenhans
1.0.5 (2020-09-29)
- Fix build for ROS2, gtest should no longer be installed in ROS2 mode
- Improve python nosetest info
- Update boost-python depend message
- Fix python module setup
- Packages can now have both a python module and a python api
- Add qtbase5-dev key
- Contributors: Fabian Poggenhans, Kevin Rösch, Maximilian Naumann
1.0.4 (2020-08-12)
- Deleted deprecated configuration files
- Fix cuda host compiler used for cuda 11
- Fix __init__.py template for python3
- Fix target handling for ros2
- Fix build failures on ROS1
- Fix the conan support
- Add a dependency on ros_environment to ensure ROS_VERSION is set
- Default to building shared libraries
- Add QtScript to the list of qt components
- Change license to BSD
- Remove traces of GPL-licensed libgps
- Remove unnecessary includes of cuda files
- Update tensorflow c findscript to set new tensorflow include paths
- Add cuda support for node and nodelet.
- Remove usage of ast package for evaulating package.xml conditions
- Fix crash if eval_coverage.py runs with python3
- Ensure that coverage is also generated for cpp code called from plain rostests
- Contributors: Fabian Poggenhans, Ilia Baltashov, Sven Richter
1.0.3 (2020-05-25)
- Replace deprecated platform.distro call with distro module
- Raise required CMake version to 3.0.2 to suppress warning with Noetic
- Remove boost signals component that is no longer part of boost
- Fixed c++14 test path include.
- Fix installation of python api files
- Update README.md
- Reformat with new version of cmake-format
- Add lcov as dependency again
- Fix FindBoostPython.cmake for cmake below 3.11 and python3
- Fix multiple include of MrtPCL
- Contributors: Christian-Eike Framing, Fabian Poggenhans, Johannes Beck, Johannes Janosovits, Moritz Cremer
1.0.2 (2020-03-24)
- Fix PCL findscript, disable precompiling
- added jsoncpp
- Make sure packages search for mrt_cmake_modules in their package config
- Fix resolution of packages in underlaying workspaces
- Mention rosdoc.yaml in package.xml
- Contributors: Fabian Poggenhans, Johannes Beck, Johannes Janosovits
1.0.1 (2020-03-11)
- Update maintainer
- Update generate_dependency_file to search CMAKE_PREFIX_PATH for packages instead of ROS_PACKAGE_PATH
- Update package xml to contain ROS urls and use format 3 to specify python version specific deps
- Add a rosdoc file so that ros can build the cmake api
- Contributors: Fabian Poggenhans
1.0.0 (2020-02-24)
- Initial release for ROS
- Contributors: Andre-Marcel Hellmund, Claudio Bandera, Fabian Poggenhans, Johannes Beck, Johannes Graeter, Niels Ole Salscheider, Piotr Orzechowski
Wiki Tutorials
Package Dependencies
Deps | Name |
---|---|
catkin | |
ament_cmake_core | |
ros_environment | |
gtest_vendor |
System Dependencies
Launch files
Messages
Services
Plugins
Recent questions tagged mrt_cmake_modules at Robotics Stack Exchange
mrt_cmake_modules package from mrt_cmake_modules repomrt_cmake_modules |
|
Package Summary
Tags | No category tags. |
Version | 1.0.11 |
License | BSD |
Build type | CATKIN |
Use | RECOMMENDED |
Repository Summary
Checkout URI | https://github.com/KIT-MRT/mrt_cmake_modules.git |
VCS Type | git |
VCS Version | master |
Last Updated | 2024-09-20 |
Dev Status | MAINTAINED |
CI status | Continuous Integration : 0 / 0 |
Released | RELEASED |
Tags | No category tags. |
Contributing |
Help Wanted (0)
Good First Issues (0) Pull Requests to Review (0) |
Package Description
Additional Links
Maintainers
- Kevin Rösch
- Fabian Poggenhans
Authors
- Fabian Poggenhans
- Johannes Beck
MRT CMake Modules (Massively Reduced Time writing CMake Modules(*))
Maintainer status: maintained
- Maintainer: Kevin Rösch, Fabian Poggenhans
- Author: Johannes Beck, Claudio Bandera, Fabian Poggenhans
- License: BSD, some files MIT
- Bug / feature tracker: https://gitlab.mrt.uni-karlsruhe.de/MRT/mrt_cmake_modules/issues
- Source: git https://gitlab.mrt.uni-karlsruhe.de/MRT/mrt_cmake_modules.git (branch: master)
Imagine you whould never have to write a CMakeLists.txt file again. Never forget to install everything, no need to update it whenever you add a file, not time lost for figuring out how to call and use find_package
for your dependencies, etc.
Well, this is exactly what mrt_cmake_modules
do for you! The only thing you have to do is:
- Keep your files in a fixed structure,
- keep library and executable code in separate packages and
- make sure the package.xml actually contains all the packages you depend on.
If you don’t want to agree to this, there are ways to get this done as well. This will require you to modify our template file a bit.
On the other hand, you get a lot of things for free:
- Resolution of your dependencies in CMake
- Automatic generation of Nodes/Nodelets
- Supports C++ and Python(2/3)
- Python bindings for pybind11/boost-python
- Automated unittest detection and execution (including ROS tests)
- Automated code coverage generation
- Support for sanitizers
- Support for running clang-tidy
- Automated install of your scripts/launchfiles/executables/libraries… to the correct location
- experimental support for ROS2 and Conan builds
) Actually MRT stands for *Institut für Mess- und Regelungstechnik, the institute that develops this package.
Building
mrt_cmake_modules
is kept as leightweight as possible. It just contains a few CMake (and python) scripts. Its only dependency is catkin
and lcov
(for code coverage).
Getting started
Interested? In order to get the CMake template file, you have to run a small script: rosrun mrt_cmake_modules generate_cmakelists.py <package_name> [--ros] [--exe]
.
This will create a CMakeLists.txt file ready to be used in your project. We distinguish four different types of packages (this the --ros
and --exe
flags):
-
Library package: They have no dependency to ros (except catkin). Their goal is to either build a
lib<package>.so
, contain only headers, contain a python module, contain python bindings. Or a mixture of these. And unittests, of course. - Ros library package (–ros): Similar to the above, but can also contain message, action or configuration files
- Executable package (–exe): Provides either a number of executables, scripts or python modules for these scripts. And unittests of course.
- Node/Nodelet package (–ros –exe): Provides a number of nodes or nodelets, python nodes and launchfiles. And rostests of course.
Package structure
The best way to understand how packages have to be layed out is to have a look at the tree of an example package, and what it implies on the build.
Libraries
Here is the structure of a package called example_package
. It works out of the box with a CMakeLists.txt created with generate_cmakelists.py example_package --ros
:
.
├── CMakeLists.txt # The generated CMakeLists
├── include # The headers of this package. Available in the whole package
│ └── example_package # It is a ROS convention to keep them within include/<package_name>
│ ├── a_header.hpp
│ └── internal # Headers here are only to be used within cpp files of this package
│ └── internal_header.hpp
├── msg
│ └── a_message.msg # Messages files that will be automatically generated (only available for --ros)
├── package.xml # You should know that. Should contain at least pybind11-dev for the bindings
├── python_api # Folder for python bindings. Every file here becoms a module
│ ├── python_bindings.cpp # Will be available as "import example_package.python_bindings"
│ └── more_python_bindings.cpp # Refer to the pybind11 doc for the content of this file
├── README.md # The readme
├── src # Every cpp file in this filder will become part of libexample_package.so
│ ├── examplefile.cpp
│ ├── onemorefile.cpp
│ └── example_package # Python modules have to go to src/<package_name>
│ ├── pythonmodule.py # Will be available as "import example_package.pythonmodule"
│ └── __init__.py
└── test # Contains the unittests. Will be executed when running the test or run_tests target
├── test_example_package.cpp # Every file here will be a separate unittest executable
└── test_pyapi.py # Every py file that matches the testMatch regular expression will be executed
# using nosetest. Executables are ignored. See https://nose.readthedocs.io/
Note that everything in this structure is optional and can be left away if you don’t need it (except for the CMakeLists.txt of course).
Executables, Nodes and Nodelets
Here is the structure of a package called example_package_ros_tool
.
It works out of the box with a CMakeLists.txt created with generate_cmakelists.py example_package_ros_tool --exe --ros
:
.
├── CMakeLists.txt
├── cfg
│ └── ConfigFile.cfg # Files to be passed to dynamic_reconfigure
├── launch # Contains launch files provided by this package
│ ├── some_node.launch
│ ├── some_nodelet.launch
│ ├── some_python_node.launch
│ └── params # Contains parameter files that will be installed
│ ├── some_parameters.yaml
│ └── some_python_parameters.yaml
├── nodelet_plugins.xml # Should reference the nodelet library at lib/lib<package_name>-<nodename>-nodelet
├── package.xml # The manifest. It should reference the nodelet_plugins.xml
├── README.md
├── scripts # Executable scripts that will be installed. These can be python nodes as well
│ ├── bias_python_node.py
│ └── bias_script.sh
├── src # Every folder in here will be a node/nodelet or both
│ ├── nodename # nodename is the name of the node/nodelet
│ │ ├── somefile.cpp # Files compiled into the node and the nodelet
│ │ ├── somefile.hpp
│ │ ├── some_node.cpp # files ending with _node will end up being compiled into the node executable
│ │ └── a_nodelet.cpp # files ending whth _nodelet will end up as part of the nodelet library
│ └── example_package_ros_tool # python modules have to go to src/<package_name>.
│ ├── node_module_python.py # These files can provide the node implementation for the scripts
│ └── __init__.py
└── test # The unittests
├── test_node.cpp # Every pair of .cpp and .test files represents one rostest
├── test_node.test
├── test.cpp # A cpp file without a matching .test a normal unittest and launched without ROS
├── node_python_test.py # Same for .py and .test files with the same name. The .py file must be executable!
└── node_python_test.test
For a normal, non-ros executable the structure is similar, but simpler. Every folder in the src file will become the name of an executable, and all cpp files within it will be part of the executable.
Generating code coverage
By default, your project is compiled without code coverage information. This can be changed by setting the cmake parameter MRT_ENABLE_COVERAGE
(e.g. by configuring cmake with -DMRT_ENABLE_COVERAGE=true
).
Setting this requires a recompilation of the project.
If this is set, running the run_tests
target will run the unittests and afterwards automatically generate an html coverage report.
The location is printed in the command line. If you set MRT_ENABLE_COVERAGE=2
, it will also be opened in firefox afterwards.
Sanitizing your code
The Sanitizers Asan, Tsan and UBsan are great ways of detecting bugs at runtime.
Sadly, you cannot enable them all as once, because Tsan cannot be used together with Asan and UBsan.
You can enable them similarly to the code coverage by setting the MRT_SANITIZER
cmake variable. It has two possible values:
- checks (enables Asan and UBsan)
- check_race (enables tsan)
If one of the sanitzers discovers an error at runtime, it will be printed to cerr.
Using clang-tidy
Clang-tidy checks your code statically at compile time for patterns of unsave or wrong code. Using this feature requires clang-tidy to be installed.
You might also want to provide a .clang-tidy file within your project that enables the checks of your choice. Refere to clang-tidys documentation for details.
You can enable clang-tidy by setting the CMake variable MRT_CLANG_TIDY
.
If you set it to “check”, clang-tidy will be run at compile time alongside the normal compiler and print all issues as compiler errors. If you set it to “fix” the recommended fixes will be applied directly to your code. Careful: Not all fixes ensure that the code compiles. Also the “fix” mode of clang-tidy is not thread safe, meaning that if you compile with multiple threads, multiple clang-tidy instances might try to fix the same file at the same time.
How dependency resolution works in detail
The mrt_cmake_modules parse your manifest file (i.e. package.xml
) in order to figure out your dependencies. The following lines in the CMakeLists.txt
are responsible for this:
find_package(mrt_cmake_modules REQUIRED) # finds this module
include(UseMrtStdCompilerFlags) # sets some generally useful compiler/warning flags
include(GatherDeps) # collects your dependencies and writes them into DEPENDEND_PACKAGES
find_package(AutoDeps REQUIRED COMPONENTS ${DEPENDEND_PACKAGES}) # resolves your dependencies by calling find_package appropriately.
AutoDeps then figures out, which includes, libraries and targets are needed in order to build this package.
The result is written into MRT_INCLUDE_DIRS
, MRT_LIBRARIES
and MRT_LIBRARY_DIRS
. These variables should be passed to the cmake targets.
The magic that happens under the hood can be understood by looking at the cmake.yaml within this project. It defines, for which dependency in the package.xml which findscript has to be searched and what variables
it will set by the script if successful. These will then be appended to the MRT_*
variables.
CMake API
This package contains a lot of useful cmake functions that are automatically available in all packages using the mrt_cmake_modules as dependency, e.g. mrt_install()
, mrt_add_node_and_nodelet()
, mrt_add_library()
, etc.
The automatically generated file already makes use of them, but you can also use them in your custom CMakeLists.
See here for a full documentation.
Findscripts
This package also contains a collection of find-scripts for thirdparty dependencies that are usually not shipped with a findscript. These are required by AutoDeps.
Going further
After you have saved time writing cmake boilerplate, it is now time to also save time writing ROS boilerplate. You might want to look into the rosinterface_handler as well. It is already intergrated in the CMakeLists template.
All you have to do is write a .rosif
file, and this project will automatically handle reading parameters from the parameter server, creating subscribers and publishers and handling reconfigure callbacks for you!
Changelog for package mrt_cmake_modules
1.0.11 (2024-09-20)
- Merge pull request #38 from nobleo/fix/find-flann-cmake-module fix(FindFLANN): set(FLANN_FOUND ON) if target already defined
- Contributors: keroe
1.0.10 (2024-07-26)
- FindGeographicLib: Fix for GeographicLib 2.* and Windows Since GeographicLib version 2, the library name changed from [libGeographic.so]{.title-ref} to [libGeographicLib.so]{.title-ref}, see https://github.com/geographiclib/geographiclib/blob/5e4425da84a46eb70e59656d71b4c99732a570ec/NEWS#L208 . To ensure that GeographicLib 2.* is found correcty, I think we should add also [GeographicLib]{.title-ref} to the names used by [find_library]{.title-ref}. Furthermore, on Windows the import library is called [GeographicLib-i.lib]{.title-ref} (see https://github.com/geographiclib/geographiclib/blob/v2.3/src/CMakeLists.txt#L119), so to find the library correctly on Windows we also look for GeographicLib-i .
- add ortools
- Revert "mrt_add_library now adds a compilation tests for all headers used by the library" This reverts commit b05cac0200ce6b8de8e8a18789dbd58cd9d8d1eb.
- Merge branch 'master' into HEAD
- Changes how the check for formatting is done. Now the CI job uses the --check flag provided by cmake_format instead of the [git diff]{.title-ref} check, because git caused some problems in this repo.
- format
- mrt_add_library now adds a compilation tests for all headers used by the library
- Add ZeroMQ
- Add zxing-cpp to cmake.yaml.
- hard coded ignore files which start with "mocs_compilation and delete the corresponding gcda file, because otherwise our current coverage pipeline fails.
- Contributors: Fabian Poggenhans, Jan-Hendrik Pauls, Johannes Beck, Kevin Rösch, Mrt Builder, Yinzhe Shen
1.0.9 (2021-11-26)
- Set python version
- Set PYTHON_EXECUTABLE for rolling
- Add find script and cmake.yml entry for proj.
- Update FLANN find script to work with newer versions.
- add boost iostreams component
- Removed debug message.
- Fix find boost python for cmake 3.20.
- add xerces and curl to camke.yaml
- Fix warnings in CUDA code.
- Remove cmake 3.20-only syntax
- Headers from dependencies are no longer marked as system, except from overlayed workspaces
- Set the ccache base dir as environment variable of the compiler command
- add pangolin
- Fix formatting of test failures on python3
- Fix recovering from sanitizer issues by making sure the flag is set only once resolves MRT/draft/simulation_adenauerring#34
- fix action build
- Use mrt_cgal again (brings a newer version than ubuntu)
- Adding or-tools to cmake.yaml.
- Sanitizers: enable recovering form nullptr issues even in no_recover mode this fixes otherwise unfixable issues e.g. in boost::serialization using this
- Update/remove old maintainer emails
- Improve evaluation of conditions in package.xml in order to make it more compliant with REP149
- Increase character limits for conditions specified package.xml This is necessary so that conditions that are based on ROS_DISTRO can be specified
- Add cmake entry for libnlopt-cpp-dev, new for focal
- Fix python script installation (shebang replacement)
- Add mrt_casadi to cmake.yaml
- Add mrt_hpipm to cmake.yaml
- Add mrt_blasfeo to cmake.yaml
- Add a small Readme pointing to cmake-format
- change name to match internal name
- add mrt-osqp-eigen
- add osqp
- Fix aravis find script.
- Switch to use aravis 0.8.
- Contributors: Fabian Poggenhans, Ilia Baltashov, Johannes Beck, Kevin Rösch, Maximilian Naumann, Piotr Orzechowski, Bernd Kröper, wep21
1.0.8 (2020-09-30)
- Fix finding boost python on versions with old cmake but new boost
- Contributors: Fabian Poggenhans
1.0.7 (2020-09-30)
- Fix versioning of sofiles
- Ensure unittests use the right gtest include dir
- Contributors: Fabian Poggenhans
1.0.6 (2020-09-30)
- Fix boost python building for python3
- Contributors: Fabian Poggenhans
1.0.5 (2020-09-29)
- Fix build for ROS2, gtest should no longer be installed in ROS2 mode
- Improve python nosetest info
- Update boost-python depend message
- Fix python module setup
- Packages can now have both a python module and a python api
- Add qtbase5-dev key
- Contributors: Fabian Poggenhans, Kevin Rösch, Maximilian Naumann
1.0.4 (2020-08-12)
- Deleted deprecated configuration files
- Fix cuda host compiler used for cuda 11
- Fix __init__.py template for python3
- Fix target handling for ros2
- Fix build failures on ROS1
- Fix the conan support
- Add a dependency on ros_environment to ensure ROS_VERSION is set
- Default to building shared libraries
- Add QtScript to the list of qt components
- Change license to BSD
- Remove traces of GPL-licensed libgps
- Remove unnecessary includes of cuda files
- Update tensorflow c findscript to set new tensorflow include paths
- Add cuda support for node and nodelet.
- Remove usage of ast package for evaulating package.xml conditions
- Fix crash if eval_coverage.py runs with python3
- Ensure that coverage is also generated for cpp code called from plain rostests
- Contributors: Fabian Poggenhans, Ilia Baltashov, Sven Richter
1.0.3 (2020-05-25)
- Replace deprecated platform.distro call with distro module
- Raise required CMake version to 3.0.2 to suppress warning with Noetic
- Remove boost signals component that is no longer part of boost
- Fixed c++14 test path include.
- Fix installation of python api files
- Update README.md
- Reformat with new version of cmake-format
- Add lcov as dependency again
- Fix FindBoostPython.cmake for cmake below 3.11 and python3
- Fix multiple include of MrtPCL
- Contributors: Christian-Eike Framing, Fabian Poggenhans, Johannes Beck, Johannes Janosovits, Moritz Cremer
1.0.2 (2020-03-24)
- Fix PCL findscript, disable precompiling
- added jsoncpp
- Make sure packages search for mrt_cmake_modules in their package config
- Fix resolution of packages in underlaying workspaces
- Mention rosdoc.yaml in package.xml
- Contributors: Fabian Poggenhans, Johannes Beck, Johannes Janosovits
1.0.1 (2020-03-11)
- Update maintainer
- Update generate_dependency_file to search CMAKE_PREFIX_PATH for packages instead of ROS_PACKAGE_PATH
- Update package xml to contain ROS urls and use format 3 to specify python version specific deps
- Add a rosdoc file so that ros can build the cmake api
- Contributors: Fabian Poggenhans
1.0.0 (2020-02-24)
- Initial release for ROS
- Contributors: Andre-Marcel Hellmund, Claudio Bandera, Fabian Poggenhans, Johannes Beck, Johannes Graeter, Niels Ole Salscheider, Piotr Orzechowski
Wiki Tutorials
Package Dependencies
Deps | Name |
---|---|
catkin | |
ament_cmake_core | |
ros_environment | |
gtest_vendor |