File: mrpt_from_cmake.rst

package info (click to toggle)
mrpt 1%3A2.5.8%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 87,448 kB
  • sloc: cpp: 551,662; ansic: 38,702; xml: 3,914; python: 2,547; sh: 404; makefile: 237
file content (59 lines) | stat: -rw-r--r-- 1,467 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
.. _mrpt_from_cmake:

####################################
Using MRPT in your CMake project
####################################

.. note::
    See online complete example with a CMake + .cpp file `here <https://github.com/MRPT/mrpt/tree/develop/doc/mrpt_example1>`_.

Finding MRPT from CMake
-------------------------

MRPT defines exported projects that can be imported as usual in modern CMake:

.. code-block:: cmake

  # Find all MRPT libraries:
  find_package(MRPT 2.0 COMPONENTS poses gui OPTIONAL_COMPONENTS vision)
  message(STATUS "MRPT_VERSION: ${MRPT_VERSION}")
  message(STATUS "MRPT_LIBRARIES: ${MRPT_LIBRARIES}")

  # Define your own targets:
  add_executable(myapp  main.cpp)

  # Link against MRPT: this will also add all required flags,
  # include directories, etc.
  target_link_libraries(myapp ${MRPT_LIBRARIES})

or individually like:


.. code-block:: cmake

  # Find MRPT libraries, one by one:
  find_package(mrpt-poses)
  find_package(mrpt-gui)

  # Define your own targets:
  add_executable(myapp  main.cpp)

  # Link against MRPT: this will also add all required flags,
  # include directories, etc.
  target_link_libraries(myapp
    mrpt::poses
    mrpt::gui
  )

For MRPT 1.x
-------------------------

Prior to MRPT 2.0.0, the correct way to search for MRPT was:

.. code-block:: cmake

  # Find MRPT libraries:
  find_package(MRPT REQUIRED poses gui)

  add_executable(myapp  main.cpp)
  target_link_libraries(myapp ${MRPT_LIBRARIES})