diff --git a/CMake/LofarMacros.cmake b/CMake/LofarMacros.cmake index 7995cc094c79f6ee0607e7df796869b1224f2767..2f6ed8829b9a9452ad0413f65787c28fb28f145b 100644 --- a/CMake/LofarMacros.cmake +++ b/CMake/LofarMacros.cmake @@ -178,22 +178,39 @@ if(NOT DEFINED LOFAR_MACROS_INCLUDED) # -------------------------------------------------------------------------- - # lofar_add_sysconf_files([name1 [name2 ..]]) + # lofar_add_sysconf_files([name1 [name2 ..]] [DESTINATION subdir]) # # Add system configuration files (read-only single machine data) that need # to be installed into the <prefix>/etc directory. Also create a symbolic # link in <build-dir>/etc to each of these files. The file names may contain # a relative(!) path. + # + # The mentioned files are installed in the same relative path as provided, + # that is: + # lofar_add_sysconf_files(foo/bar) + # installs "etc/foo/bar". To override this behaviour use: + # lofar_add_sysconf_files(foo/bar DESTINATION .) + # installs "etc/bar". # -------------------------------------------------------------------------- macro(lofar_add_sysconf_files) - foreach(_name ${ARGN}) - get_filename_component(_path ${_name} PATH) - get_filename_component(_abs_name ${_name} ABSOLUTE) + string(REGEX REPLACE ";?DESTINATION.*" "" _srcs "${ARGN}") + string(REGEX MATCH "DESTINATION;.*" _dest "${ARGN}") + string(REGEX REPLACE "^DESTINATION;" "" _dest "${_dest}") + foreach(_src_name ${_srcs}) + if(_dest MATCHES ".+") + get_filename_component(_dst_name ${_src_name} NAME) + else(_dest MATCHES ".+") + set(_dst_name ${_src_name}) + endif(_dest MATCHES ".+") + + get_filename_component(_abs_name ${_src_name} ABSOLUTE) + get_filename_component(_dst_path ${_dst_name} PATH) + file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/etc/${_path}) execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink - ${_abs_name} ${CMAKE_BINARY_DIR}/etc/${_name}) - install(FILES ${_name} DESTINATION etc/${_path}) - endforeach(_name ${ARGN}) + ${_abs_name} ${CMAKE_BINARY_DIR}/etc/${_dst_name}) + install(FILES ${_src_name} DESTINATION etc/${_dst_path}) + endforeach(_src_name ${ARGN}) endmacro(lofar_add_sysconf_files)