arclight
arclight

Reputation: 1608

Convincing CPack to properly install shared read-only data under /usr/share

I am configuring CMake/CPack to install an application which ships with a few read-only shared data files. My understanding is that according to the FHS, such files should be stored under /usr/share, ideally within an application-specific directory (e.g. /usr/share/my_project) rather than directly under /usr/share. I am using GNUInstallDirs as an attempt to stay within (my understanding of) the expectations of the FHS using the following:

#...

include(GNUInstallDirs)

# BAD: Installs files from ${CMAKE_CURRENT_SOURCE_DIR}/data
# into /usr/share
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/data/"
  TYPE DATA
)

# GOOD: Installs files from ${CMAKE_CURRENT_SOURCE_DIR}/data
# into /usr/share/${PROJECT_NAME}
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/data/"
  DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}"
)

#...

Everything works as it's documented; my questions are:

  1. Am I understanding the FHS correctly that (ideally) I should put my applications' shared read-only data under /usr/share/my_project?
  2. If that's the case, am I using TYPE DATA wrong in INSTALL(DIRECTORY ...)? That is, should I copy all my data to ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME} then use INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME} TYPE DATA). That seems like a waste.
  3. Otherwise, if I'm misunderstanding where this type of data should be installed, where should it go, and is TYPE DATA the right way to use install(DIRECTORY ...)? Or do I still need to use an explicitly-specified DESTINATION?

I guess this is a nice way of asking if GNUInstallDirs and TYPE DATA are fit-for-purpose and compatible with the FHS or not. My main goal is to have CMake/CPack Just Put Things Where They Are Supposed To Live without needing to explicitly specify the proper location for each platform's installer.

Upvotes: 1

Views: 264

Answers (0)

Related Questions