diff --git a/cmake/DeployMacros.cmake b/cmake/DeployMacros.cmake index fec5f314..3c01f544 100644 --- a/cmake/DeployMacros.cmake +++ b/cmake/DeployMacros.cmake @@ -40,7 +40,10 @@ # # # -# deploy_target( [DEPLOY_DIR ] [DESTINATION ] [RESOURCE_DIRS [ ...]] [PLUGIN_DIRS [ ...]]) +# deploy_target( [DEPLOY_DIR ] [DESTINATION ] +# [RESOURCES [ ...]] +# [PLUGINS [ ...]] +# [FILES [ ...]]) # # DEPLOY_DIR - dir where you install # * executable on Windows, Linux @@ -273,30 +276,60 @@ END endmacro() +macro(__add_file_or_dir _DIR_VAR _FILE_VAR _PATH) + set(_p) + if (IS_ABSOLUTE "${_PATH}") + set(_p "${_PATH}") + else() + set(_p "${CMAKE_CURRENT_SOURCE_DIR}/${_PATH}") + endif() + if (EXISTS "${_p}") + if (IS_DIRECTORY "${_p}") + list(APPEND ${_DIR_VAR} "${_p}") + else() + list(APPEND ${_FILE_VAR} "${_p}") + endif() + endif() +endmacro() + + macro(deploy_target _T) set(_DESTINATION "${CMAKE_INSTALL_PREFIX}") set(_DEPLOY_DIR "${CMAKE_INSTALL_PREFIX}") set(_RES_DIRS) + set(_RES_FILES) set(_PLUG_DIRS) + set(_PLUG_FILES) + set(_FILE_DIRS) + set(_FILE_FILES) set(_is_dest 0) set(_is_deploy_dir 0) - set(_is_res_dirs 0) - set(_is_plug_dirs 0) + set(_is_res 0) + set(_is_plug 0) + set(_is_file 0) foreach(_i ${ARGN}) if ("x${_i}" STREQUAL "xDESTINATION") - set(_is_res_dirs 0) - set(_is_plug_dirs 0) + set(_is_res 0) + set(_is_plug 0) + set(_is_file 0) set(_is_dest 1) elseif ("x${_i}" STREQUAL "xDEPLOY_DIR") - set(_is_res_dirs 0) - set(_is_plug_dirs 0) + set(_is_res 0) + set(_is_plug 0) + set(_is_file 0) set(_is_deploy_dir 1) - elseif ("x${_i}" STREQUAL "xRESOURCE_DIRS") - set(_is_res_dirs 1) - set(_is_plug_dirs 0) - elseif ("x${_i}" STREQUAL "xPLUGIN_DIRS") - set(_is_res_dirs 0) - set(_is_plug_dirs 1) + elseif ("x${_i}" STREQUAL "xRESOURCES") + set(_is_res 1) + set(_is_plug 0) + set(_is_file 0) + elseif ("x${_i}" STREQUAL "xPLUGINS") + set(_is_res 0) + set(_is_plug 1) + set(_is_file 0) + elseif ("x${_i}" STREQUAL "xFILES") + set(_is_res 0) + set(_is_plug 0) + set(_is_file 1) else() if (_is_dest) set(_is_dest 0) @@ -304,18 +337,12 @@ macro(deploy_target _T) elseif (_is_deploy_dir) set(_is_deploy_dir 0) set(_DEPLOY_DIR "${_i}/") - elseif (_is_res_dirs) - if (IS_ABSOLUTE "${_i}") - list(APPEND _RES_DIRS "${_i}") - else() - list(APPEND _RES_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/${_i}") - endif() - elseif (_is_plug_dirs) - if (IS_ABSOLUTE "${_i}") - list(APPEND _PLUG_DIRS "${_i}") - else() - list(APPEND _PLUG_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/${_i}") - endif() + elseif (_is_res) + __add_file_or_dir(_RES_DIRS _RES_FILES "${_i}") + elseif (_is_plug) + __add_file_or_dir(_PLUG_DIRS _PLUG_FILES "${_i}") + elseif (_is_file) + __add_file_or_dir(_FILE_DIRS _FILE_FILES "${_i}") endif() endif() #message("-i = ${_i}") @@ -372,18 +399,20 @@ macro(deploy_target _T) set(_C_echo ">>" "${_AGD}/DEBIAN/control") set(_D_echof ">" "${_AGD}/usr/share/applications/${_DEBNAME}.desktop") set(_D_echo ">>" "${_AGD}/usr/share/applications/${_DEBNAME}.desktop") - if (_RES_DIRS) - set(_CMD_COPY ${_CMD_COPY} COMMAND mkdir -p "${_AGD}/usr/share/${${_T}_COMPANY}") - endif() - foreach(_d ${_RES_DIRS}) - set(_CMD_COPY ${_CMD_COPY} COMMAND cp -r "${_d}" "${_AGD}/usr/share/${${_T}_COMPANY}") - endforeach() - if (_PLUG_DIRS) - set(_CMD_COPY ${_CMD_COPY} COMMAND mkdir -p "${_AGD}/usr/lib/${${_T}_COMPANY}") - endif() - foreach(_d ${_PLUG_DIRS}) - set(_CMD_COPY ${_CMD_COPY} COMMAND cp -r "${_d}" "${_AGD}/usr/lib/${${_T}_COMPANY}") - endforeach() + macro(__make_copy _cmd _dirs _files _dest) + if (_dirs OR _files) + set(${_cmd} ${${_cmd}} COMMAND mkdir -p "${_dest}") + endif() + foreach(_d ${${_dirs}}) + set(${_cmd} ${${_cmd}} COMMAND cp -rf "${_d}" "${_dest}/") + endforeach() + foreach(_f ${${_files}}) + set(${_cmd} ${${_cmd}} COMMAND cp -f "${_f}" "${_dest}/") + endforeach() + endmacro() + __make_copy(_CMD_COPY _RES_DIRS _RES_FILES "${_AGD}/usr/share/${${_T}_COMPANY}") + __make_copy(_CMD_COPY _PLUG_DIRS _PLUG_FILES "${_AGD}/usr/lib/${${_T}_COMPANY}") + __make_copy(_CMD_COPY _FILE_DIRS _FILE_FILES "${_AGD}/usr/bin") if (_DEP_LIBS) set(_CMD_COPY ${_CMD_COPY} COMMAND cp -f ${_DEP_LIBS} ${_AGD}/usr/lib) endif()