Reputation: 1608
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:
/usr/share/my_project
?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.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