cmake#
Gazebo CMake : CMake Modules for Gazebo Projects
Maintainer: scpeters AT openrobotics.org
Table of Contents
Features
gz-cmake provides a set of cmake modules that are used by the C++ based Gazebo projects. These modules help to control the quality and consistency of the Gazebo projects build systems.
These modules are tailored to the Gazebo projects, so their use for non-Gazebo projects might be limited, but they may serve as a useful reference for setting up a modern cmake build system using good practices.
Install
We recommend following the Binary Install instructions to get up and running as quickly and painlessly as possible.
The Source Install instructions should be used if you need the very latest software improvements, you need to modify the code, or you plan to make a contribution.
Binary Install
On Ubuntu systems, apt-get
can be used to install gz-cmake
:
$ sudo apt install libgz-cmake<#>-dev
Be sure to replace <#>
with a number value, such as 1
or 2
, depending on which version you need.
Source Install
Prerequisites
The only prerequisite of gz-cmake
is cmake
. Ubuntu users can install cmake with the package manager:
$ sudo apt install cmake
Building from source
To build and install from source, you can clone the repo and use cmake to install the modules as though this is a regular cmake project:
$ git clone https://github.com/gazebosim/gz-cmake
$ cd gz-cmake
$ mkdir build
$ cd build
$ cmake .. -DCMAKE_INSTALL_PREFIX=/path/to/install/dir
$ make -j8
$ make install
Replace /path/to/install/dir
to whatever directory you want to install this package to.
Usage
Documentation can be accessed at https://gazebosim.org/libs/cmake
Examples are available in this repository.
Tutorials are also available in this repository.
Documentation
Documentation for gz-cmake
can be found within the source code, and also in the MIGRATION.md guide.
Testing
A fuller suite of tests in the examples
directory can be enabled by building with BUILDSYSTEM_TESTING
enabled.
Tests can be run by building the test
target. From your build directory you can run:
$ cmake .. -DBUILDSYSTEM_TESTING=1
$ make test
Folder Structure
cmake
: cmake modules that get installed by this packagecodecheck
: code linting and static analyzing utilities that get installed by this packageconfig
: template files for producing the config-files ofgz-cmake
; these are only used internallydoc
: template files to help Gazebo projects generate their own documentationexamples
: fake projects that are used to testgz-cmake
include
: C++ utility header files that get installed withgz-cmake
test
: a directory of tests for the C++ utility component ofgz-cmake
tools
: scripts for continuous integration testing
Contributing
Please see the contribution guide.
Code of Conduct
Please see CODE_OF_CONDUCT.md.
Versioning
This library uses Semantic Versioning. Additionally, this library is part of the Gazebo project which periodically releases a versioned set of compatible and complementary libraries. See the Gazebo website for version and release information.
License
This library is licensed under Apache 2.0. See also the LICENSE file.
Gazebo CMake 4.x
Gazebo CMake 4.1.0 (2024-11-01)
Update add-to-project version in triage.yml
Helper to get version number from package.xml
Gazebo CMake 4.0.0 (2024-09-25)
Miscellaneous documentation fixes
Use relative paths for pkg-config install directory
Deprecate
BUILD_DOCS
: generate always the doc target but exclude from default makeAccept arbitrary capitalization for coverage build type
Deprecate GzPython.cmake in favor of
find_package(Python3)
Use default flags for RelWithDebInfo
Use visibility hidden by default
Replace
exec_program
withexecute_process
Doxygen: exclude C++
__attribute__
Require cmake version 3.22.1
CI: disable 20.04, enable 24.04
Deprecate SuppressWarning.hh with
#warning
Remove ignition
Bump major version to 4
Gazebo CMake 3.x
Gazebo CMake 3.5.3 (2024-05-02)
Fix installation of Ign*.cmake modules on newer versions of CMake
Add package.xml
Remove example_INSTALL_DIR from PREFIX_PATH on examples
Gazebo CMake 3.5.2 (2024-04-05)
Use relative install paths for extra cmake files
Gazebo CMake 3.5.1 (2024-03-29)
Fix how
ign
compatibility files are copied in windows
Gazebo CMake 3.5.0 (2024-03-14)
Remove @mxgrey as codeowner and assign maintainership to @scpeters
Replace
exec_program
withexecute_process
cppcheck uses c++17
Preserve executable permissions when installing scripts
Use a consistent Python interpreter in all scripts
Drop shebang from
upload_doc.sh
Use a relative symlink for
Ign*
cmake modulesRemove exec_program call
Update CI badges in README
Infrastructure
Change
EXTRA_ARGS
to be amultiValueArgs
inGzFindPackage
Gazebo CMake 3.4.1 (2023-09-26)
Fixed finding Ogre2 on Windows+Conda
Gazebo CMake 3.4.0 (2023-08-25)
Only link against DL in the case that it is needed
Disable building examples by default
FindIgnOgre*: fix LIBRARY_DIRS and PLUGINDIR resolution when using pkgconfig
Use CONFIG in gz_add_benchmark to avoid Windows collisions
Gazebo CMake 3.3.1 (2023-08-03)
Fix pkg_config_entry when version number is not specified
Infrastructure
Gazebo CMake 3.3.0 (2023-07-10)
GzConfigureProject: improve documentation
Compute relative path for cmake extras
GzConfigureProject: fix extras install
Gazebo CMake 3.2.2 (2023-06-26)
Fix incorrect if comparison in build_examples
Fix finding ogre 2.3 installed from source
Gazebo CMake 3.2.1 (2023-05-30)
Check for empty variables before performing REPLACE
GzSetCompilerFlags: Fix detection of clang-cl
Gazebo CMake 3.2.0 (2023-05-19)
Add support for adding cmake extras to packages
Build examples using native CMake
Split gzutils into functional pieces
Enable ign_ warnings to push the transition to gz_
Gazebo CMake 3.1.0 (2023-04-21)
Add optional binary relocatability in downstream libraries
Thanks to Silvio Traversaro
Fix doxygen warnings.
Thanks to Benjamin Perseghetti
Use CONFIG in gz_add_benchmark to avoid Windows collisions
Unset cache variable in gz_pkg_check_modules_quiet
LICENSE: add Apache 2.0 license text
Disable protobuf warnings on protobuf target (#335)
Pull request #335) (#336 (#336)
Disable protobuf warnings on protobuf target
Fix FindAVDEVICE.cmake in case without pkg-config installed with ffmpeg >= 5.1
Gazebo CMake 3.0.1 (2022-10-11)
FindIgnOGRE2: preserve PKG_CONFIG_PATH
FindSQLite3: Add SQLite::SQLite3 ALIAS
FindUUID: Do not wrap LIBRARY_NAMES argument with quotes
Disable source tooltips
Don’t assume
CMAKE_INSTALL_*DIR
variables are relative
Gazebo CMake 3.0.0 (2022-09-23)
CMake macro to find the assimp library
Changes for OGRE-2.3
Migrate ign -> gz
Removed hardcoded gtest include folder
Deprecate utilities in favor of ign-utils
Replace deprecated PythonInterp with Python3
Disable long-running buildsystem tests by default
Infrastructure
Gazebo CMake 2.x
Gazebo CMake 2.17.1 (2023-08-31)
FindIgnOgre*: fix LIBRARY_DIRS and PLUGINDIR resolution when using pkgconfig
Gazebo CMake 2.17.0 (2023-05-19)
Use CONFIG in gz_add_benchmark to avoid Windows collisions
LICENSE: add Apache 2.0 license text
Disable protobuf warnings on protobuf target (#335)
Fix FindAVDEVICE.cmake in case without pkg-config installed with ffmpeg >= 5.1
Gazebo CMake 2.16.0 (2022-10-08)
FindIgnOGRE2: preserve PKG_CONFIG_PATH
FindSQLite3: Add SQLite::SQLite3 ALIAS
FindUUID: Do not wrap LIBRARY_NAMES argument with quotes
Don’t assume
CMAKE_INSTALL_*DIR
variables are relativeRemove check for s3cfg
Gazebo CMake 2.15.0 (2022-08-29)
ign -> gz: add
gz/*
header filesBackport
GZ_SANITIZER
variableUpdate doxygen file
Gazebo CMake 2.14.0 (2022-07-25)
Add code coverage ignore file
Gazebo CMake 2.13.0 (2022-07-22)
Backport
GZ_DESIGNATION
tick-tockUpload docs to an s3 bucket based only on the major version
Exclude proto generated cpp in coverage test
Add LTCG flag on Windows builds
Update codeowners
Update documentation to gazebosim.org
Improving CONFIG test
Gazebo CMake 2.12.1 (2022-04-12)
Allow to recreate targets created by GzPkgConfig
Adding tests for CONFIG argument
Gazebo CMake 2.12.0 (2022-04-11)
Adding CONFIG option
GzFindOGRE2: support for the ogre-next package on Ubuntu Jammy
Fix check for missing components in OGRE2. Be more verbose with components
FindGzOGRE2: exclude ogre versions different than 2.x
Specify sanitizers using GZ_SANITIZERS cmake variable
Replace deprecated PythonInterp with Python3 (#213)
Gazebo CMake 2.11.0 (2022-02-23)
Set source path to be used by common::testing
Add examples using static libraries
Gazebo CMake 2.10.0 (2021-12-21)
doxygen allow all .cc, .hh, and CMakeLists.txt, not just in examples/ dir
Add
LEGACY_PROJECT_PREFIX
parameter togz_create_core_library
Add
HIDE_SYMBOLS_BY_DEFAULT
parameter togz_configure_build
Add Ubuntu Jammy CI
FindGzURDFDOM cmake module
Do not modify
CMAKE_FIND_LIBRARY_PREFIXES
andCMAKE_FIND_LIBRARY_SUFFIXES
on WindowsProject option:
REPLACE_INCLUDE_PATH
Project option:
NO_PROJECT_PREFIX
Gazebo CMake 2.9.0 (2021-09-02)
Fix include directory flags for codecheck
Fix problems on GzOGRE when version is not found
Remove bitbucket-pipelines.yml
Include IMAGE_PATH directories in gz_create_docs
Special case for ogre2.2 on Windows
Fix building OGRE / OGRE2 from source in colcon workspace
Remove codecov badge from README
Port codecov to new configuration
Gazebo CMake 2.8.0 (2021-04-30)
Fix hardcoded pkg-config library in examples
User-friendly skip component warning
Run gz-cmake’s copy of check_test_ran
Gazebo CMake 2.7.0 (2021-03-30)
Support to find Ogre 2-2
glib fix for Windows
Fix cmake message types
Support imported targets in FindGzOGRE.cmake
Infrastructure
Set cmake CMP0079 policy
Tutorial about building with cmake and colcon
Add an option to disable docs when building
Install hpp files as headers
Suppress warning C5205 on Windows
Windows installation instructions via conda-forge
Ensure relocatable config files
Gazebo CMake 2.6.2 (2020-12-29)
FindUUID: Always define UUID::UUID on Apple platforms
Remove deprecated doxygen configurations
Generate doxygen tutorials for gz-cmake
Enable make codecheck for gz-cmake
Generate valid visibility macros by replacing hyphens in component name
Gazebo CMake 2.6.1 (2020-12-10)
Revert python to optional dependency
Gazebo CMake 2.6.0 (2020-12-08)
Added build-essential and cmake to packages.apt
Fix FindGzOgre on Windows when not using vcpkg
FindGzOGRE2: prefer versioned component libraries
Correct CMake logic and update cpplint to Python3
Improve fork experience
Gazebo CMake 2.5.0 (2020-09-05)
Add additional input directories to parse when generating documentation
Gazebo CMake 2.4.0 (2020-08-20)
Added an option to include generated code in the gz_create_docs function
Gazebo CMake 2.3.0 (2020-08-07)
New macros to help with filter google-test in some platforms
Disable long-running buildsystem tests by default
Fix use of FindYAML.cmake and FindJSONCPP without pkg-config
Fix use of FindGzOGRE2 on Windows if OGRE2 is not found
Thanks to Silvio Traversaro
FindUUID: Export include path as expected by Gazebo Libraries #104
Thanks to Silvio Traversaro
Make the OGRE plugin path discovery portable
Thanks to Sean Yen
Gazebo CMake 2.2.0
Fix use of FindZIP without pkg-config.
Use mathjax to render equations.
Reduce example names to fix build on Windows
Fix doxygen deprecation filter
Change the diamond link icon to a material design link
Disable long-running buildsystem tests by default.
Set viewport for doxygen pages.
Use upstream
CURL::libcurl
imported target in FindGzCURL.cmake if available.Avoid hardcoding /machine:x64 flag on 64-bit on MSVC.
FindGzOGRE2: fix include paths for new directory structure.
Support for custom vcpkg ogre2 windows port (backport of PR 155).
GzConfigureBuild: only
add_subdirectory(test)
ifBUILD_TESTING
is ONAdd FindGzBullet cmake module.
Gazebo CMake 2.1.1 (2019-08-07)
Turn on doxygen warnings, add CI script to check for doxygen warnings.
Gazebo CMake 2.1.0 (2019-05-17)
Fixes for vcpkg ogre 1.11 version
Add benchmark aggregation functionality
Use
PRIVATE_FOR
to skip cmake dependencies in addition to pkg-configupload_doc.sh
: actually use dry-run, and allow the user to pass in a ‘y’ or ‘n’Set favicon
Fix tagfile generation by preventing the inclusion of tutorials
Update datainstall dir
Allow tests to build without automatic linking against project lib
Gazebo CMake 2.0.0 (2019-01-31)
Require cmake 3.10.2, support
CXX_STANDARD
17
Gazebo CMake 1.x
Set viewport for doxygen pages.
Use upstream
CURL::libcurl
imported target in FindGzCURL.cmake if available.Avoid hardcoding /machine:x64 flag on 64-bit on MSVC.
GzConfigureBuild: only
add_subdirectory(test)
ifBUILD_TESTING
is ONFix race condition in test for issue 48
Account for inter-component dependencies when importing targets
Gazebo CMake 1.1.0
Initial version bumped to 1.1.0 since there was a 1.1.0 prerelease
Gazebo CMake 1.0.0
* [Full list of changes](https://github.com/gazebosim/gz-cmake/compare/ignition-cmake1_1.0.0...ign-cmake0)
Gazebo CMake 0.x
Set viewport for doxygen pages.
Use upstream
CURL::libcurl
imported target in FindGzCURL.cmake if available.Avoid hardcoding /machine:x64 flag on 64-bit on MSVC.
GzConfigureBuild: only
add_subdirectory(test)
ifBUILD_TESTING
is ONGzConfigureProject.cmake: fix small typo PKCONFIG -> PKGCONFIG
Gazebo CMake 0.6.1
Fix duplicated imported target error
Gazebo CMake 0.6.0
Properly mark internal CMake cache variables as advanced
Make line coverage by default, add separate coverage-branch target
Refactor variable names in example test junit templates
Suport for
CMAKE_BUILD_TYPE
None
Gazebo CMake 0.5.0
FindJSONCPP: fix target when pkg-config is successful
Add branch coverage
Add FindOptiX.cmake
Gazebo CMake 0.4.1
* [Full list of changes](https://github.com/gazebosim/gz-cmake/compare/ignition-cmake_0.4.1...ignition-cmake_0.4.0)
Gazebo CMake 0.4.0