Configure your build for installing data files

From Wiki for iCub and Friends
Revision as of 13:18, 18 December 2013 by (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

These simple instructions show how to configure your build to install data files (xml and config files for applications and modules).

First make sure you find YARP and extend CMAKE_MODULE_PATH to make cmake scripts in YARP visible.

find_package(YARP REQUIRED)
# Pick up our scripts - they are all in the conf subdirectory

Then call:


which brings in a set of YARP macros.

If you want to install data files inside directories specific to your project, you should add:


Where PACKAGE is the name of your build/project. This line modifies YARP installation so that it can locate the data files you will install with your project; furthermore, it will create for you the following CMake variables:

  • <PACKAGE>_CONTEXTS_INSTALL_DIR for "context" folders, containing configuration files and data that modules look for at runtime
  • <PACKAGE>_PLUGIN_MANIFESTS_INSTALL_DIR for plugin manifest files
  • <PACKAGE>_APPLICATIONS_INSTALL_DIR for XML files describing applications (collections of modules and connections between them)
  • <PACKAGE>_MODULES_INSTALL_DIR for XML files describing modules (including input/output ports)
  • <PACKAGE>_ROBOTS_INSTALL_DIR for robot-specific configuration files
  • <PACKAGE>_TEMPLATES_INSTALL_DIR generic directory for templates; it is however advised to use specific applications/modules templates install directories
  • <PACKAGE>_APPLICATIONS_TEMPLATES_INSTALL_DIR for application templates (XML files with .template extension), which need to be properly customized
  • <PACKAGE>_MODULES_TEMPLATES_INSTALL_DIR for module templates (should not be needed)
  • <PACKAGE>_DATA_INSTALL_DIR generic directory for data; it is however advised to use more specific directories
  • <PACKAGE>_CONFIG_INSTALL_DIR generic directory for configuration files

Now you can install additional data files by using the macro yarp_install, e.g.:

set (appname myApplication)
file(GLOB conf ${CMAKE_CURRENT_SOURCE_DIR}/conf/*.ini)
file(GLOB templates ${CMAKE_CURRENT_SOURCE_DIR}/scripts/*.template)
file(GLOB scripts ${CMAKE_CURRENT_SOURCE_DIR}/scripts/*.xml)
yarp_install(FILES ${conf} DESTINATION ${<PACKAGE>_CONTEXTS_INSTALL_DIR}/${appname})

Otherwise, you can skip the yarp_configure_external_installation(PACKAGE) step and use YARP's own data directories, e.g.:

yarp_install(FILES ${conf} DESTINATION ${YARP_CONTEXTS_INSTALL_DIR}/${appname})

Please note that these CMake variables define relative paths, where data will be installed with respect to the installation prefix you configure your build with (CMAKE_INSTALL_PREFIX CMake variable); for YARP to be able to find these files, you need to make sure that the installation prefix for your build matches the one for YARP, or you will need to tweak your environment by setting the YARP_DATA_DIRS environment variable.