diff --git a/utils/cmake/deploy.cmake b/utils/cmake/deploy.cmake index 4a43c033fa..95c384bcef 100644 --- a/utils/cmake/deploy.cmake +++ b/utils/cmake/deploy.cmake @@ -39,37 +39,66 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux") -DOUTDIR=${CMAKE_BINARY_DIR} -DURL=https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage -P ${CMAKE_CURRENT_LIST_DIR}/download.cmake - ) - # intermediate target needed to be able to get back to the actual file dependency. - add_custom_target(linuxdeploy DEPENDS ${LINUXDEPLOY}) - function(deploy_qt target qtbindir iconfile desktopfile dmgbuildcfg) + ) + # intermediate target needed to be able to get back to the actual file dependency. + add_custom_target(linuxdeploy DEPENDS ${LINUXDEPLOY}) + + function(deploy_qt) + cmake_parse_arguments(deploy "" + "TARGET;DESKTOPFILE;ICONFILE;QTBINDIR;DMGBUILDCFG" + "EXECUTABLES" + ${ARGN}) if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") message(WARNING "Deploying a Debug build.") endif() + add_custom_target(deploy_${deploy_TARGET} + DEPENDS ${CMAKE_BINARY_DIR}/${deploy_TARGET}.AppImage) + + # need extra rules so we can use generator expressions + # (using get_target_property() doesn't know neede values during generation) + set(_deploy_deps "") + foreach(_deploy_exe_tgt ${deploy_EXECUTABLES}) + add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/${_deploy_exe_tgt}.appimage.stamp + COMMENT "Copying ${_deploy_exe_tgt} to AppImage" + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/AppImage-${deploy_TARGET}/usr/bin + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ + ${CMAKE_BINARY_DIR}/AppImage-${deploy_TARGET}/usr/bin + COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/${_deploy_exe_tgt}.appimage.stamp + DEPENDS ${_deploy_exe_tgt} + ) + add_custom_target(deploy_${deploy_TARGET}_${_deploy_exe_tgt} + DEPENDS ${CMAKE_BINARY_DIR}/${_deploy_exe_tgt}.appimage.stamp) + + set(_deploy_deps "${_deploy_deps};deploy_${deploy_TARGET}_${_deploy_exe_tgt}") + endforeach() + add_custom_command( - OUTPUT ${CMAKE_BINARY_DIR}/${target}.AppImage - COMMENT "Creating AppImage ${target}" - COMMAND OUTPUT=${CMAKE_BINARY_DIR}/${target}.AppImage + OUTPUT ${CMAKE_BINARY_DIR}/${deploy_TARGET}.AppImage + COMMENT "Creating AppImage ${deploy_TARGET}" + COMMAND OUTPUT=${CMAKE_BINARY_DIR}/${deploy_TARGET}.AppImage ${LINUXDEPLOY} --plugin qt - --icon-file=${iconfile} - --desktop-file=${desktopfile} - --executable=$ - --appdir=AppImage-${target} + --icon-file=${deploy_ICONFILE} + --desktop-file=${deploy_DESKTOPFILE} + --executable=$ + --appdir=${CMAKE_BINARY_DIR}/AppImage-${deploy_TARGET} --output=appimage --verbosity=2 - DEPENDS ${target} linuxdeploy + DEPENDS ${deploy_TARGET} ${_deploy_deps} linuxdeploy ) - add_custom_target(deploy_${target} - DEPENDS ${CMAKE_BINARY_DIR}/${target}.AppImage) - add_dependencies(deploy deploy_${target}) + add_dependencies(deploy deploy_${deploy_TARGET}) endfunction() endif() # MacOS: Build dmg if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - function(deploy_qt target qtbindir iconfile desktopfile dmgbuildcfg) + function(deploy_qt) + cmake_parse_arguments(deploy "" + "TARGET;DESKTOPFILE;ICONFILE;QTBINDIR;DMGBUILDCFG" + "EXECUTABLES" + ${ARGN}) if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") message(WARNING "Deploying a Debug build.") endif() @@ -77,6 +106,25 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") set(DMGBUILD_STAMP ${CMAKE_BINARY_DIR}/dmgbuild.stamp) find_program(MACDEPLOYQT_EXECUTABLE macdeployqt HINTS "${qtbindir}") + # need extra rules so we can use generator expressions + # (using get_target_property() doesn't know neede values during generation) + set(_deploy_deps "") + foreach(_deploy_exe_tgt ${deploy_EXECUTABLES}) + add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/${_deploy_exe_tgt}.app.stamp + COMMENT "Copying ${_deploy_exe_tgt} to App" + COMMAND ${CMAKE_COMMAND} -E make_directory $/bin + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ + $/bin + COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/${_deploy_exe_tgt}.app.stamp + DEPENDS ${_deploy_exe_tgt} + ) + add_custom_target(deploy_${deploy_TARGET}_${_deploy_exe_tgt} + DEPENDS ${CMAKE_BINARY_DIR}/${_deploy_exe_tgt}.app.stamp) + + set(_deploy_deps "${_deploy_deps};deploy_${deploy_TARGET}_${_deploy_exe_tgt}") + endforeach() + add_custom_command( COMMENT "Setting up dmgbuild virtualenv" OUTPUT ${DMGBUILD_STAMP} @@ -86,62 +134,83 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") add_custom_command( # TODO: find a better way to figure the app bundle name. - OUTPUT ${CMAKE_BINARY_DIR}/${target}.dmg - COMMENT "Running macdeployqt and creating dmg ${target}" - COMMAND ${MACDEPLOYQT_EXECUTABLE} ${target}.app - COMMAND ${DMGBUILD} -s ${dmgbuildcfg} - -Dappbundle=${target}.app - ${target} ${CMAKE_BINARY_DIR}/${target}.dmg - DEPENDS ${target} + OUTPUT ${CMAKE_BINARY_DIR}/${deploy_TARGET}.dmg + COMMENT "Running macdeployqt and creating dmg ${deploy_TARGET}" + COMMAND ${MACDEPLOYQT_EXECUTABLE} ${deploy_TARGET}.app + COMMAND ${DMGBUILD} -s ${deploy_DMGBUILDCFG} + -Dappbundle=${deploy_TARGET}.app + ${deploy_TARGET} ${CMAKE_BINARY_DIR}/${deploy_TARGET}.dmg + DEPENDS ${deploy_TARGET} ${DMGBUILD_STAMP} + ${_deploy_deps} ) - add_custom_target(deploy_${target} - DEPENDS ${CMAKE_BINARY_DIR}/${target}.dmg) - add_dependencies(deploy deploy_${target}) + add_custom_target(deploy_${deploy_TARGET} + DEPENDS ${CMAKE_BINARY_DIR}/${deploy_TARGET}.dmg) + add_dependencies(deploy deploy_${deploy_TARGET}) endfunction() endif() # Windows. Copy to dist folder, run windeployqt on the binary, compress to zip. if(CMAKE_SYSTEM_NAME STREQUAL "Windows") - function(deploy_qt target qtbindir iconfile desktopfile dmgbuildcfg) + function(deploy_qt) + cmake_parse_arguments(deploy "" + "TARGET;DESKTOPFILE;ICONFILE;QTBINDIR;DMGBUILDCFG" + "EXECUTABLES" + ${ARGN}) if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") message(WARNING "Deploying a Debug build.") endif() - set(_targetfile ${target}.exe) # TODO: Use property. OUTPUT_NAME seems to fail. find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${qtbindir}") - set(deploydir ${CMAKE_BINARY_DIR}/deploy-${target}) + set(deploydir ${CMAKE_BINARY_DIR}/deploy-${deploy_TARGET}) if(WINDEPLOYQT_EXECUTABLE) add_custom_command( COMMENT "Creating deploy folder and running windeployqt" - OUTPUT ${deploydir}/${_targetfile} + OUTPUT ${deploydir}/${deploy_TARGET} COMMAND ${CMAKE_COMMAND} -E make_directory ${deploydir} - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_targetfile} ${deploydir} + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ ${deploydir} COMMAND ${WINDEPLOYQT_EXECUTABLE} $,--debug,--release> # on MinGW, release is mistaken as debug. - ${deploydir}/${_targetfile} - DEPENDS ${target} + ${deploydir}/$ + DEPENDS ${deploy_TARGET} ) else() add_custom_command( COMMENT "Creating deploy folder" - OUTPUT ${deploydir}/${_targetfile} + OUTPUT ${deploydir}/${deploy_TARGET} COMMAND ${CMAKE_COMMAND} -E make_directory ${deploydir} - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_targetfile} ${deploydir} - DEPENDS ${target} + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ ${deploydir} + DEPENDS ${deploy_TARGET} ) endif() + # need extra rules so we can use generator expressions + # (using get_target_property() doesn't know neede values during generation) + set(_deploy_deps "") + foreach(_deploy_exe_tgt ${deploy_EXECUTABLES}) + add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/${_deploy_exe_tgt}.app.stamp + COMMENT "Copying ${_deploy_exe_tgt} to deploy folder" + COMMAND ${CMAKE_COMMAND} -E make_directory ${deploydir} + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ ${deploydir} + COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/${_deploy_exe_tgt}.app.stamp + DEPENDS ${_deploy_exe_tgt} + ) + add_custom_target(deploy_${deploy_TARGET}_${_deploy_exe_tgt} + DEPENDS ${CMAKE_BINARY_DIR}/${_deploy_exe_tgt}.app.stamp) + + set(_deploy_deps "${_deploy_deps};deploy_${deploy_TARGET}_${_deploy_exe_tgt}") + endforeach() add_custom_command( COMMENT "Compressing to zip" - OUTPUT ${CMAKE_BINARY_DIR}/${target}.zip + OUTPUT ${CMAKE_BINARY_DIR}/${deploy_TARGET}.zip WORKING_DIRECTORY ${deploydir} - COMMAND ${CMAKE_COMMAND} -E tar c ${CMAKE_BINARY_DIR}/${target}.zip + COMMAND ${CMAKE_COMMAND} -E tar c ${CMAKE_BINARY_DIR}/${deploy_TARGET}.zip --format=zip . - DEPENDS ${deploydir}/${_targetfile} + DEPENDS ${deploydir}/${deploy_TARGET} ${_deploy_deps} ) - add_custom_target(deploy_${target} - DEPENDS ${CMAKE_BINARY_DIR}/${target}.zip) - add_dependencies(deploy deploy_${target}) + add_custom_target(deploy_${deploy_TARGET} + DEPENDS ${CMAKE_BINARY_DIR}/${deploy_TARGET}.zip) + add_dependencies(deploy deploy_${deploy_TARGET}) endfunction() endif() diff --git a/utils/rbutilqt/CMakeLists.txt b/utils/rbutilqt/CMakeLists.txt index d0ac4d9a54..2293b8ebc4 100644 --- a/utils/rbutilqt/CMakeLists.txt +++ b/utils/rbutilqt/CMakeLists.txt @@ -137,11 +137,13 @@ set_property(TARGET RockboxUtility PROPERTY AUTOMOC ON) set_property(TARGET RockboxUtility PROPERTY AUTORCC ON) set_property(TARGET RockboxUtility PROPERTY AUTOUIC ON) -deploy_qt(RockboxUtility - ${QT_BINDIR} - ${CMAKE_CURRENT_LIST_DIR}/../../docs/logo/rockbox-clef.svg - ${CMAKE_CURRENT_LIST_DIR}/RockboxUtility.desktop - ${CMAKE_CURRENT_LIST_DIR}/dmgbuild.cfg) +deploy_qt(TARGET RockboxUtility + QTBINDIR ${QT_BINDIR} + ICONFILE ${CMAKE_CURRENT_LIST_DIR}/../../docs/logo/rockbox-clef.svg + DESKTOPFILE ${CMAKE_CURRENT_LIST_DIR}/RockboxUtility.desktop + DMGBUILDCFG ${CMAKE_CURRENT_LIST_DIR}/dmgbuild.cfg + EXECUTABLES ipodpatcher-bin sansapatcher-bin + ) add_library(rbbase ${CMAKE_CURRENT_LIST_DIR}/../../tools/iriver.c diff --git a/utils/themeeditor/CMakeLists.txt b/utils/themeeditor/CMakeLists.txt index d0957a96da..b29265898a 100644 --- a/utils/themeeditor/CMakeLists.txt +++ b/utils/themeeditor/CMakeLists.txt @@ -142,8 +142,9 @@ if(APPLE) PROPERTIES MACOSX_PACKAGE_LOCATION Resources) endif() -deploy_qt(RockboxThemeEditor - ${QT_BINDIR} - ${CMAKE_CURRENT_LIST_DIR}/resources/rbthemeeditor.svg - ${CMAKE_CURRENT_LIST_DIR}/RockboxThemeEditor.desktop - ${CMAKE_CURRENT_LIST_DIR}/dmgbuild.cfg) +deploy_qt(TARGET RockboxThemeEditor + QTBINDIR ${QT_BINDIR} + ICONFILE ${CMAKE_CURRENT_LIST_DIR}/resources/rbthemeeditor.svg + DESKTOPFILE ${CMAKE_CURRENT_LIST_DIR}/RockboxThemeEditor.desktop + DMGBUILDCFG ${CMAKE_CURRENT_LIST_DIR}/dmgbuild.cfg) +