Install example config files dynamically.

They'll only get installed when the distribution version differs
from existing version on disk.
This commit is contained in:
Jon Siwek 2011-07-29 17:29:17 -05:00
parent 0e5bc16a60
commit ca95ad9618
3 changed files with 16 additions and 6 deletions

View file

@ -3,7 +3,6 @@ include(InstallClobberImmune)
# This macro can be used to install configuration files which
# users are expected to modify after installation. It will:
#
# - Always install one version of the file with a .example suffix
# - If binary packaging is enabled:
# Install the file in the typical CMake fashion, but append to the
# INSTALLED_CONFIG_FILES cache variable for use with the Mac package's
@ -19,10 +18,6 @@ include(InstallClobberImmune)
macro(InstallPackageConfigFile _srcfile _dstdir _dstfilename)
set(_dstfile ${_dstdir}/${_dstfilename})
# Always install the latest version of the file renamed as an example
install(FILES ${_srcfile} DESTINATION ${_dstdir}
RENAME ${_dstfilename}.example)
if (BINARY_PACKAGING_MODE)
# If packaging mode is enabled, always install the distribution's
# version of the file. The Mac package's pre/post install scripts
@ -32,6 +27,14 @@ macro(InstallPackageConfigFile _srcfile _dstdir _dstfilename)
# use to avoid clobbering user-modified config files
set(INSTALLED_CONFIG_FILES
"${INSTALLED_CONFIG_FILES} ${_dstfile}" CACHE STRING "" FORCE)
# Additionally, the Mac PackageMaker packages don't have any automatic
# handling of configuration file conflicts so install an example file
# that the post install script will cleanup in the case it's extraneous
if (APPLE)
install(FILES ${_srcfile} DESTINATION ${_dstdir}
RENAME ${_dstfilename}.example)
endif ()
else ()
# Have `make install` check at run time whether the file does not exist
InstallClobberImmune(${_srcfile} ${_dstfile})