wiki:cmake_modules

Various cmake modules are used by the flair build system. They are located in flair-dev.

You will find some explanations of what they do here. But the best way to understand them is to read them!

Cmake modules

ArchDir.cmake

Retrieves the arch name from the toolchain file (toolchain.cmake). It is used to install files in the correct folders, and to check if a lib, demo or tool is compatible with a specific architecture or not.

It also checks if host architecture is i686, as it is not supported.

ColoredMessage.cmake

Defines some cmake functions to have colored messages.

FindXenomai.cmake

Find xenomai lib and defines some variables useful for cmake.

GlobalCmakeFlair.cmake

reimplements some cmake built in functions to add extra functionalities

  • ADD_EXECUTABLE:
    • add a message to display architecture
    • check if $HOME/.ssh/config have some hosts defined (see here). In this case add a custom_target to cmake, to copy the executable with ssh. The custom target is called delivery_root_ADDRESS_PATH, with address the target address and path the destination path.
    • copy demos binaries. To enable this functionality, you need to add SET(FLAIR_DEMO_DEST_DIR yourproject) to your CMakeLists.txt, see this example. Files will be copied to $FLAIR_ROOT/flair-install/bin/demos/${ARCH_DIR}/yourproject
  • ADD_LIBRARY:
    • add a message to display architecture.
    • add compile info in a .h (used by libs constructor), see in FlairMeta for example.
  • INSTALL:
    • copy resources files (scripts and xml files for the demos). Resources files are placed in the resources dir, and inside an arch dir. See for example in the CircleFollower demo. These files are not overwritten if they already exist. To enable this functionality, you need to add SET(FLAIR_RESOURCE_FILES_DEST_DIR yourproject) to your CMakeLists.txt, see this example. Files will be copied to $FLAIR_ROOT/flair-install/bin/demos/${ARCH_DIR}/yourproject

FlairUseFile.cmake

Used by demos/tools, it helps adding include dirs and libraries for programs using flair.

It performs some checks:

  • presence of libxml2 in the toolchain
  • presence of xenomai in the toolchain
  • gcc version (must be >= 4.3)
  • presence of a flair-hds directory. For Heudiasyc users, see here

Needed include dirs and libraries are determined using some boolean variables:

  • FLAIR_USE_SIMULATOR
  • FLAIR_USE_VRPN
  • FLAIR_USE_GPS
  • FLAIR_USE_VISION_FILTER
  • FLAIR_USE_SENSOR_ACTUATOR
  • FLAIR_USE_FILTER
  • FLAIR_USE_META

You have to set these variables to true in your CMakeLists.txt, if you need need these functionalities.

In return, FlairUseFile.cmake will fill 3 variables:

  • ${FLAIR_INCLUDE_DIR}: list of needed include dirs
  • ${FLAIR_LIBRARIES_RT}: list of needed libraries for real time (xenomai)
  • ${FLAIR_LIBRARIES_NRT}: list of needed libraries for non real time

Take a look at CircleFollower demo CMakeLists.txt file to see how it is used.

Last modified 17 months ago Last modified on Feb 20, 2019, 4:00:33 PM