Difference between revisions of "Configure your build for installing data files"

From Wiki for iCub and Friends
Jump to navigation Jump to search
 
Line 1: Line 1:
These simple instructions show how to configure your build to install data files (xml and config files for applications and modules).
These simple instructions show how to configure your build to install data files (xml and config files for applications and modules).
This step is only needed if you want to install these files within


First make sure you find YARP and extend CMAKE_MODULE_PATH to make cmake scripts in YARP visible.
First make sure you find YARP and extend CMAKE_MODULE_PATH to make cmake scripts in YARP visible.
Line 11: Line 10:


  include(YarpInstallationHelpers)
  include(YarpInstallationHelpers)
yarp_configure_external_installation(BUILD)


Where ''BUILD'' is the name of your build/project. The first call brings in a set of YARP macros. The second line modifies YARP installation so that it can locate the data files you will install in your build.
which brings in a set of YARP macros.
 
If you want to install data files inside directories specific to your project, you should add:
 
yarp_configure_external_installation(PACKAGE)
 
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.:
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 conf ${CMAKE_CURRENT_SOURCE_DIR}/conf/*.ini)
  file(GLOB templates ${CMAKE_CURRENT_SOURCE_DIR}/scripts/*.template)
  file(GLOB templates ${CMAKE_CURRENT_SOURCE_DIR}/scripts/*.template)
  file(GLOB scripts ${CMAKE_CURRENT_SOURCE_DIR}/scripts/*.xml)
  file(GLOB scripts ${CMAKE_CURRENT_SOURCE_DIR}/scripts/*.xml)


  yarp_install(FILES ${conf} DESTINATION ${BUILD_CONTEXTS_INSTALL_DIR}/${appname})
  yarp_install(FILES ${conf} DESTINATION ${<PACKAGE>_CONTEXTS_INSTALL_DIR}/${appname})
  yarp_install(FILES ${templates} DESTINATION ${BUILD_APPLICATIONS_TEMPLATES_INSTALL_DIR})
  yarp_install(FILES ${templates} DESTINATION ${<PACKAGE>_APPLICATIONS_TEMPLATES_INSTALL_DIR})
  yarp_install(FILES ${scripts} DESTINATION ${BUILD_APPLICATIONS_INSTALL_DIR})
  yarp_install(FILES ${scripts} DESTINATION ${<PACKAGE>_APPLICATIONS_INSTALL_DIR})
 
 
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})
yarp_install(FILES ${templates} DESTINATION ${YARP_APPLICATIONS_TEMPLATES_INSTALL_DIR})
yarp_install(FILES ${scripts} DESTINATION ${YARP_APPLICATIONS_INSTALL_DIR})
 
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 [[ResourceFinder#Extending the search path|setting the YARP_DATA_DIRS environment variable]].

Latest revision as of 13:18, 18 December 2013

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
list(APPEND CMAKE_MODULE_PATH ${YARP_MODULE_PATH})

Then call:

include(YarpInstallationHelpers)

which brings in a set of YARP macros.

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

yarp_configure_external_installation(PACKAGE)

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})
yarp_install(FILES ${templates} DESTINATION ${<PACKAGE>_APPLICATIONS_TEMPLATES_INSTALL_DIR})
yarp_install(FILES ${scripts} DESTINATION ${<PACKAGE>_APPLICATIONS_INSTALL_DIR})


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})
yarp_install(FILES ${templates} DESTINATION ${YARP_APPLICATIONS_TEMPLATES_INSTALL_DIR})
yarp_install(FILES ${scripts} DESTINATION ${YARP_APPLICATIONS_INSTALL_DIR})

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.