Configure your build for installing data files

From Wiki for iCub and Friends
Revision as of 23:39, 27 November 2013 by Lorenzo (talk | contribs) (Created page with "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...")
(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
list(APPEND CMAKE_MODULE_PATH ${YARP_MODULE_PATH})

Then call:

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.

Now you can install additional data files by using the macro yarp_install, e.g. this creates an example app:

set(appname Example)
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 ${BUILD_CONTEXTS_INSTALL_DIR}/${appname})
yarp_install(FILES ${templates} DESTINATION ${BUILD_APPLICATIONS_TEMPLATES_INSTALL_DIR})
yarp_install(FILES ${scripts} DESTINATION ${BUILD_APPLICATIONS_INSTALL_DIR})