diff --git a/cmake/DeployMacros.cmake b/cmake/DeployMacros.cmake index c2876fc7..9272ba94 100644 --- a/cmake/DeployMacros.cmake +++ b/cmake/DeployMacros.cmake @@ -40,7 +40,7 @@ # # # -# deploy_target( [DEPLOY_DIR ] [DESTINATION ] [RESOURCE_DIRS [ ...]]) +# deploy_target( [DEPLOY_DIR ] [DESTINATION ] [RESOURCE_DIRS [ ...]] [PLUGIN_DIRS [ ...]]) # # DEPLOY_DIR - dir where you install # * executable on Windows, Linux @@ -51,7 +51,7 @@ # Example: # deploy_target(my_app DESTINATION packages) # -# Create make target "deploy" +# Create make target "deploy_", depends on target "deploy" # # This macro use "deploy_tool" from sdk, # make sure it can be executed from shell @@ -277,29 +277,45 @@ macro(deploy_target _T) set(_DESTINATION "${CMAKE_INSTALL_PREFIX}") set(_DEPLOY_DIR "${CMAKE_INSTALL_PREFIX}") set(_RES_DIRS) + set(_PLUG_DIRS) set(_is_dest 0) set(_is_deploy_dir 0) set(_is_res_dirs 0) + set(_is_plug_dirs 0) foreach(_i ${ARGN}) - if (_is_dest) - set(_is_dest 0) - set(_DESTINATION "${_i}/") - 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() + if ("x${_i}" STREQUAL "xDESTINATION") + set(_is_res_dirs 0) + set(_is_plug_dirs 0) + set(_is_dest 1) + elseif ("x${_i}" STREQUAL "xDEPLOY_DIR") + set(_is_res_dirs 0) + set(_is_plug_dirs 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) else() - if ("x${_i}" STREQUAL "xDESTINATION") - set(_is_dest 1) - elseif ("x${_i}" STREQUAL "xDEPLOY_DIR") - set(_is_deploy_dir 1) - elseif ("x${_i}" STREQUAL "xRESOURCE_DIRS") - set(_is_res_dirs 1) + if (_is_dest) + set(_is_dest 0) + set(_DESTINATION "${_i}/") + 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() endif() endif() #message("-i = ${_i}") @@ -326,7 +342,7 @@ macro(deploy_target _T) endif() endforeach() #message("app depend libpath ${_DEP_LIBPATH}") - set(_CMD_RES) + set(_CMD_COPY) set(_has_deploy 0) if ("x${CMAKE_SYSTEM_NAME}" STREQUAL "xLinux") if (NOT CMAKE_LDD) @@ -355,10 +371,18 @@ 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") - foreach(_r ${_RES_DIRS}) - set(_CMD_RES ${_CMD_RES} COMMAND cp -r "${_r}" "${_AGD}/usr/share/${${_T}_COMPANY}") + 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() - set(_CMD_COPY) if (_DEP_LIBS) set(_CMD_COPY ${_CMD_COPY} COMMAND cp -f ${_DEP_LIBS} ${_AGD}/usr/lib) endif() @@ -370,18 +394,16 @@ macro(deploy_target _T) COMMAND mkdir -p ${_AGD}/DEBIAN COMMAND mkdir -p ${_AGD}/usr/bin COMMAND mkdir -p ${_AGD}/usr/lib - COMMAND mkdir -p ${_AGD}/usr/share/${${_T}_COMPANY} COMMAND mkdir -p ${_AGD}/usr/share/pixmaps COMMAND mkdir -p ${_AGD}/usr/share/applications COMMAND cp -f ${_DEPLOY_DIR}/${_T} ${_AGD}/usr/bin ${_CMD_COPY} - ${_CMD_RES} COMMAND echo "Package: ${_DEBNAME}" ${_C_echof} COMMAND echo "Version: ${${_T}_VERSION}" ${_C_echo} COMMAND echo "Architecture: ${_DEB_ARCH}" ${_C_echo} COMMAND echo "Maintainer: ${${_T}_COMPANY} <>" ${_C_echo} - COMMAND deploy_tool --prefix "Depends: " --dependencies -l ${CMAKE_LDD} ${_DEPLOY_DIR}/${_T} -a "${_DEP_LIBS_CS}" -o "${_AGD}/usr/lib" ${_C_echo} + COMMAND deploy_tool --prefix "Depends: " --dependencies -l ${CMAKE_LDD} -a "${_DEP_LIBS_CS}" -o "${_AGD}/usr/lib" ${_DEPLOY_DIR}/${_T} ${_PLUG_DIRS} ${_C_echo} COMMAND echo "Conflicts:" ${_C_echo} COMMAND echo "Replaces:" ${_C_echo} COMMAND echo "Section: misc" ${_C_echo} @@ -432,16 +454,16 @@ macro(deploy_target _T) set(_MKDIR if not exist "\"${_AGD}\"" mkdir "\"${_AGD}\"") set(_MKDIR_P if not exist "\"${_DESTINATION}\"" mkdir "\"${_DESTINATION}\"") endif() - foreach(_r ${_RES_DIRS}) - get_filename_component(_dirname "${_r}" NAME) - file(TO_NATIVE_PATH "${_r}/" _wr) + foreach(_d ${_RES_DIRS} ${_PLUG_DIRS}) + get_filename_component(_dirname "${_d}" NAME) + file(TO_NATIVE_PATH "${_d}/" _wr) if ("x${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "xWindows") - set(_CMD_RES ${_CMD_RES} COMMAND if not exist "\"${_AGD}${_dirname}\"" mkdir "\"${_AGD}${_dirname}\"") + set(_CMD_COPY ${_CMD_COPY} COMMAND if not exist "\"${_AGD}${_dirname}\"" mkdir "\"${_AGD}${_dirname}\"") string(REPLACE "/" "\\" _wr "${_wr}") else() - set(_CMD_RES ${_CMD_RES} COMMAND mkdir -p "${_AGD}${_dirname}") + set(_CMD_COPY ${_CMD_COPY} COMMAND mkdir -p "${_AGD}${_dirname}") endif() - set(_CMD_RES ${_CMD_RES} COMMAND ${_COPY} "${_wr}*" "\"${_AGD}${_dirname}${_SEP}\"" ${_COPY_SUFFIX}) + set(_CMD_COPY ${_CMD_COPY} COMMAND ${_COPY} "${_wr}*" "\"${_AGD}${_dirname}${_SEP}\"" ${_COPY_SUFFIX}) endforeach() add_custom_target(deploy_${_T} # gather dir @@ -449,11 +471,11 @@ macro(deploy_target _T) COMMAND ${_MKDIR_P} COMMAND ${_COPY} "\"${_DEPLOY_DIR}${_T}.exe\"" "\"${_AGD}\"" ${_COPY_SUFFIX} #COMMAND ${_COPY} "${_DEPLOY_DIR}lang${_SEP}*" "\"${_AGD}lang${_SEP}\"" ${_COPY_SUFFIX} - ${_CMD_RES} + ${_CMD_COPY} - COMMAND deploy_tool -W "\"${CMAKE_OBJDUMP}\"" -P windows -S windows -q "\"${Qt5_ROOT}\"" -s "\"${CMAKE_PREFIX_PATH}/bin;${MINGW_BIN};${DEPLOY_ADD_LIBPATH}${_DEP_LIBPATH}\"" -o ${_AGD} -p ${_AGD} "\"${_AGD}${_T}.exe\"" + COMMAND deploy_tool -W "\"${CMAKE_OBJDUMP}\"" -P windows -S windows -q "\"${Qt5_ROOT}\"" -s "\"${CMAKE_PREFIX_PATH}/bin;${MINGW_BIN};${DEPLOY_ADD_LIBPATH}${_DEP_LIBPATH}\"" -o ${_AGD} -p ${_AGD} "\"${_AGD}${_T}.exe\"" ${_PLUG_DIRS} # zip - COMMAND cd "\"${_DEPLOY_DIR}\"" "&&" zip -r "\"${_DESTINATION}/${_TV}.zip\"" "\"${_TV}_win_${MY_ARCH}\"" + COMMAND cd "\"${_DEPLOY_DIR}\"" "&&" zip -q -r "\"${_DESTINATION}/${_TV}.zip\"" "\"${_TV}_win_${MY_ARCH}\"" COMMENT "Generating ${_TV}.zip" ) set(_has_deploy 1) @@ -471,23 +493,25 @@ macro(deploy_target _T) set_target_properties(${_T} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_ROOT}/Modules/PIMacOSBundle.plist.in") set(_AGD "${_DEPLOY_DIR}/${_T}.app") set(_DMG "${CMAKE_CURRENT_BINARY_DIR}/dmg") - set(_CMD_COPY) if (_ICON_NAME) set(_CMD_COPY ${_CMD_COPY} COMMAND cp -f ${_ICON_FN} ${_AGD}/Contents/Resources) endif() - foreach(_r ${_RES_DIRS}) - set(_CMD_RES ${_CMD_RES} COMMAND cp -r "${_r}" "${_AGD}/Contents/Resources") + foreach(_d ${_RES_DIRS}) + set(_CMD_COPY ${_CMD_COPY} COMMAND cp -r "${_d}" "${_AGD}/Contents/Resources") + endforeach() + foreach(_d ${_PLUG_DIRS}) + set(_CMD_COPY ${_CMD_COPY} COMMAND cp -r "${_d}" "${_AGD}/Contents/PlugIns") endforeach() add_custom_target(deploy_${_T} # gather .app dir COMMAND mkdir -p ${_AGD}/Contents/Resources COMMAND mkdir -p ${_AGD}/Contents/Frameworks + COMMAND mkdir -p ${_AGD}/Contents/PlugIns COMMAND mkdir -p ${_DESTINATION} ${_CMD_COPY} - ${_CMD_RES} #COMMAND cp ${_ICON_FN} ${_AGD}/Contents/Resources #COMMAND cp -r ${_DEPLOY_DIR}/lang ${_AGD}/Contents/Resources - COMMAND deploy_tool -M "${CMAKE_OTOOL}" -P cocoa -S mac -q ${Qt5_ROOT} -s "\"${CMAKE_PREFIX_PATH}/lib;${DEPLOY_ADD_LIBPATH}${_DEP_LIBPATH}\"" -o ${_AGD}/Contents/Frameworks -p ${_AGD}/Contents/PlugIns ${_AGD}/Contents/MacOS/${_T} + COMMAND deploy_tool -M "${CMAKE_OTOOL}" -P cocoa -S mac -q ${Qt5_ROOT} -s "\"${CMAKE_PREFIX_PATH}/lib;${DEPLOY_ADD_LIBPATH}${_DEP_LIBPATH}\"" -o ${_AGD}/Contents/Frameworks -p ${_AGD}/Contents/PlugIns ${_AGD}/Contents/MacOS/${_T} ${_PLUG_DIRS} # prepare dmg dir COMMAND rm -rf ${_DMG} COMMAND mkdir -p ${_DMG}