From 495740f801ccb4ce73f517a3a99ba8dacdba744c Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Tue, 7 Apr 2015 12:55:42 -0700 Subject: CMake: Initial PortableApps targets. Add portableapps_app_dir and portableapps_package targets. Change-Id: Ifea3d952eef0e267de6364999d45807236d99102 Reviewed-on: https://code.wireshark.org/review/8025 Reviewed-by: Gerald Combs --- CMakeLists.txt | 10 ++ cmake/modules/FindPortableApps.cmake | 26 ++++++ packaging/nsis/CMakeLists.txt | 15 ++- packaging/portableapps/CMakeLists.txt | 116 ++++++++++++++++++++++++ packaging/portableapps/Makefile.nmake | 13 +-- packaging/portableapps/appinfo.tmpl | 4 +- packaging/portableapps/xcopy-deploy-exclude.txt | 2 + 7 files changed, 169 insertions(+), 17 deletions(-) create mode 100644 cmake/modules/FindPortableApps.cmake create mode 100644 packaging/portableapps/CMakeLists.txt create mode 100644 packaging/portableapps/xcopy-deploy-exclude.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 780d1d7ca7..7ac850c136 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2139,6 +2139,16 @@ if (WIN32) ADD_NSIS_UNINSTALLER_TARGET() ADD_NSIS_PACKAGE_TARGET() endif() + + find_package( PortableApps ) + if ( + NOT "${PORTABLEAPPS_LAUNCHER_GENERATOR_EXECUTABLE}" STREQUAL "PORTABLEAPPS_LAUNCHER_GENERATOR_EXECUTABLE-NOTFOUND" + AND + NOT "${PORTABLEAPPS_INSTALLER_EXECUTABLE}" STREQUAL "PORTABLEAPPS_INSTALLER_EXECUTABLE-NOTFOUND" + ) + add_subdirectory( packaging/portableapps EXCLUDE_FROM_ALL ) + ADD_PORTABLEAPPS_PACKAGE_TARGET() + endif() endif() if(BUILD_androiddump) diff --git a/cmake/modules/FindPortableApps.cmake b/cmake/modules/FindPortableApps.cmake new file mode 100644 index 0000000000..17ee15ae2e --- /dev/null +++ b/cmake/modules/FindPortableApps.cmake @@ -0,0 +1,26 @@ +# +# - Find PortableApps +# Find the PortableApps LauncherGenerator and Installer commands +# +# PORTABLEAPPS_LAUNCHER_GENERATOR_EXECUTABLE - path to the PortableApps.comLauncherGenerator utility. +# PORTABLEAPPS_INSTALLER_EXECUTABLE - path to the PortableApps.comInstaller utility. + +# Find PortableApps.comLauncherGenerator +find_program(PORTABLEAPPS_LAUNCHER_GENERATOR_EXECUTABLE PortableApps.comLauncherGenerator + PATH + "C:/PortableApps/PortableApps.comLauncher" + "$ENV{USERPROFILE}/PortableApps/PortableApps.comLauncher" + DOC "Path to the PortableApps.comLauncherGenerator utility." +) + +# Find PortableApps.comInstaller +find_program(PORTABLEAPPS_INSTALLER_EXECUTABLE PortableApps.comInstaller + PATH + "C:/PortableApps/PortableApps.comInstaller" + "$ENV{USERPROFILE}/PortableApps/PortableApps.comInstaller" + DOC "Path to the PortableApps.comInstaller utility." +) + +# Assume that FindNSIS has taken care of this for us. +# set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE) +# include(InstallRequiredSystemLibraries) diff --git a/packaging/nsis/CMakeLists.txt b/packaging/nsis/CMakeLists.txt index bf56d23b37..463a38d4cf 100644 --- a/packaging/nsis/CMakeLists.txt +++ b/packaging/nsis/CMakeLists.txt @@ -22,6 +22,14 @@ # We should use CPack to generate the NSIS package. Even better, # we should use CPack to create a .msi using WIX. +set(NSIS_GENERATED_FILES + ${CMAKE_CURRENT_BINARY_DIR}/all-manifest.nsh + ${CMAKE_CURRENT_BINARY_DIR}/config.nsh + ${CMAKE_CURRENT_BINARY_DIR}/gtk-dll-manifest.nsh + ${CMAKE_CURRENT_BINARY_DIR}/qt-dll-manifest.nsh + PARENT_SCOPE +) + set(NSIS_FILES wireshark.nsi uninstall.nsi @@ -30,10 +38,7 @@ set(NSIS_FILES servicelib.nsh AdditionalTasksPage.ini WinPcapPage.ini - ${CMAKE_CURRENT_BINARY_DIR}/all-manifest.nsh - ${CMAKE_CURRENT_BINARY_DIR}/config.nsh - ${CMAKE_CURRENT_BINARY_DIR}/gtk-dll-manifest.nsh - ${CMAKE_CURRENT_BINARY_DIR}/qt-dll-manifest.nsh + ${NSIS_GENERATED_FILES} PARENT_SCOPE ) @@ -198,7 +203,7 @@ macro( ADD_NSIS_UNINSTALLER_TARGET ) endmacro( ADD_NSIS_UNINSTALLER_TARGET ) macro( ADD_NSIS_PACKAGE_TARGET ) - set (_nsis_package ${CMAKE_BINARY_DIR}/packaging/nsis/wireshark-$(WIRESHARK_TARGET_PLATFORM)-$(VERSION).exe) + set (_nsis_package ${CMAKE_BINARY_DIR}/packaging/nsis/Wireshark-$(WIRESHARK_TARGET_PLATFORM)-$(VERSION).exe) add_custom_target(nsis_package DEPENDS diff --git a/packaging/portableapps/CMakeLists.txt b/packaging/portableapps/CMakeLists.txt new file mode 100644 index 0000000000..39ce14ec93 --- /dev/null +++ b/packaging/portableapps/CMakeLists.txt @@ -0,0 +1,116 @@ +# CMakeLists.txt +# +# Wireshark - Network traffic analyzer +# By Gerald Combs +# Copyright 1998 Gerald Combs +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# + +# To do: +# - Use CPack to generate the PortableApps package. +# - Copy the C runtime DLLs if they're available. + +set(PORTABLEAPPS_NAME "${CMAKE_PROJECT_NAME}Portable") +set(PORTABLEAPPS_NAME ${PORTABLEAPPS_NAME} PARENT_SCOPE) + +set (_launcher_dir "${CMAKE_CURRENT_BINARY_DIR}/${PORTABLEAPPS_NAME}") +set (PORTABLEAPPS_LAUNCHER_STAGING_DIR ${_launcher_dir} PARENT_SCOPE) + +set(PORTABLEAPPS_DIRS + ${_launcher_dir} + ${_launcher_dir}/App + ${_launcher_dir}/App/AppInfo + ${_launcher_dir}/App/AppInfo/Launcher + ${_launcher_dir}/Data + ${_launcher_dir}/Other + ${_launcher_dir}/Other/Source + PARENT_SCOPE +) + +macro( ADD_PORTABLEAPPS_PACKAGE_TARGET ) + # Copy our binaries, libraries, and data files to the PortableApps build directory. + set(_portableapps_app_dir "${PORTABLEAPPS_LAUNCHER_STAGING_DIR}/App/${CMAKE_PROJECT_NAME}") + file(TO_NATIVE_PATH "${_portableapps_app_dir}" _portableapps_app_dir_native) + file(TO_NATIVE_PATH "${DATAFILE_DIR}" _datafile_dir_native) + file(TO_NATIVE_PATH "${CMAKE_SOURCE_DIR}/packaging/portableapps/xcopy-deploy-exclude.txt" _xcopy_deploy_exclude) + add_custom_target(portableapps_app_dir + # We "Deploy using XCopy," which is described at + # https://msdn.microsoft.com/en-us/library/ms235291.aspx + # We also assume that the project has been built at this point. + COMMAND ${CMAKE_COMMAND} -E remove_directory ${_portableapps_app_dir} + COMMAND ${CMAKE_COMMAND} -E make_directory ${_portableapps_app_dir} + COMMAND xcopy ${_datafile_dir_native} ${_portableapps_app_dir_native} /D /I /E /Y /exclude:${_xcopy_deploy_exclude} + # XXX Copy C runtime DLLs. + ) + set_target_properties(portableapps_app_dir PROPERTIES FOLDER "Packaging") + + #Build the PortableApps package. + set (_portableapps_package ${CMAKE_BINARY_DIR}/packaging/portableapps/WiresharkPortable_$(VERSION).exe) + add_custom_target(portableapps_package + DEPENDS + portableapps_app_dir + ${_portableapps_package} + ) + set_target_properties(portableapps_package PROPERTIES FOLDER "Packaging") + + set(PORTABLEAPPS_PACKAGE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO}.0") + configure_file( + ${CMAKE_SOURCE_DIR}/packaging/portableapps/appinfo.tmpl + ${PORTABLEAPPS_LAUNCHER_STAGING_DIR}/App/AppInfo/appinfo.ini + NEWLINE_STYLE WIN32 + ) + + foreach(_portableapps_dir ${PORTABLEAPPS_DIRS}) + add_custom_command(OUTPUT ${_portableapps_dir} + COMMAND ${CMAKE_COMMAND} -E make_directory ${_portableapps_dir} + ) + endforeach() + + set(_portableapps_launcher_ini ${PORTABLEAPPS_LAUNCHER_STAGING_DIR}/App/AppInfo/Launcher/${PORTABLEAPPS_NAME}.ini) + add_custom_command(OUTPUT ${_portableapps_launcher_ini} + DEPENDS + ${PORTABLEAPPS_DIRS} + ${CMAKE_SOURCE_DIR}/packaging/portableapps/${PORTABLEAPPS_NAME}.ini + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/packaging/portableapps/${PORTABLEAPPS_NAME}.ini ${_portableapps_launcher_ini} + ) + + set(_portableapps_launcher_exe ${PORTABLEAPPS_LAUNCHER_STAGING_DIR}/${PORTABLEAPPS_NAME}.exe) + file(TO_NATIVE_PATH "${PORTABLEAPPS_LAUNCHER_STAGING_DIR}" _portableapps_native ) + add_custom_command(OUTPUT ${_portableapps_launcher_exe} + DEPENDS + ${_portableapps_launcher_ini} + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/packaging/portableapps/help.html ${PORTABLEAPPS_LAUNCHER_STAGING_DIR}/help.html + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/packaging/portableapps/help.html ${PORTABLEAPPS_LAUNCHER_STAGING_DIR}/help.html + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/image/wireshark.ico ${PORTABLEAPPS_LAUNCHER_STAGING_DIR}/App/AppInfo/appicon.ico + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/image/wsicon16.png ${PORTABLEAPPS_LAUNCHER_STAGING_DIR}/App/AppInfo/appicon_16.png + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/image/wsicon32.png ${PORTABLEAPPS_LAUNCHER_STAGING_DIR}/App/AppInfo/appicon_32.png + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/image/wsicon128.png ${PORTABLEAPPS_LAUNCHER_STAGING_DIR}/App/AppInfo/appicon_128.png + COMMAND ${PORTABLEAPPS_LAUNCHER_GENERATOR_EXECUTABLE} ${_portableapps_native} + ) + + add_custom_command(OUTPUT ${_portableapps_package} + DEPENDS + ${PORTABLEAPPS_DIRS} + ${CMAKE_BINARY_DIR}/packaging/portableapps/appinfo.ini + ${_portableapps_launcher_exe} + COMMAND ${PORTABLEAPPS_INSTALLER_EXECUTABLE} ${_portableapps_native} + ) +endmacro( ADD_PORTABLEAPPS_PACKAGE_TARGET ) + +#set(CLEAN_FILES +# ${_launcher_dir} +# ${_portableapps_package} +#) diff --git a/packaging/portableapps/Makefile.nmake b/packaging/portableapps/Makefile.nmake index efe08ea07e..6a25f928d0 100644 --- a/packaging/portableapps/Makefile.nmake +++ b/packaging/portableapps/Makefile.nmake @@ -19,11 +19,6 @@ SOURCE = $(OTHER)\Source APPINFO_INI = $(APPINFO)\appinfo.ini LAUNCHER_INI = $(LAUNCHER_DIR)\$(PROGRAM_PORTABLE).ini -WSMANIFEST = ../wireshark.manifest - -NSIS_PLUGINS = nsis-plugins -FINDPROCDLL = $(WIRESHARK_LIB_DIR)\$(NSIS_PLUGINS)\FindProcDLL.dll - COPY = xcopy MKDIR = mkdir COPY_FLAGS = /d /y @@ -31,8 +26,6 @@ COPY_FLAGS = /d /y WIN32_SETUP_OPT = --download !ENDIF -NSIS_DIR = $(TOPDIR)\packaging\nsis - # XXX This should be defined in config.nmake. !IF EXIST("$(TOPDIR)\wireshark-qt-release\wireshark.exe") QT_DIR = "$(TOPDIR)\wireshark-qt-release" @@ -47,7 +40,7 @@ NEED_QT4_DLL = USE UPX_FLAGS = -q PAPPS_VERSION=$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_MICRO).0 -PAPPS_PACKAGE=$(PROGRAM_PORTABLE)-$(VERSION).paf.exe +PAPPS_PACKAGE=$(PROGRAM_PORTABLE)_$(VERSION).paf.exe all: package @@ -77,8 +70,8 @@ dirs: #!ENDIF $(APPINFO_INI): dirs appinfo.tmpl $(TOPDIR)\config.nmake - sed -e 's/$$(PAPPS_VERSION)/$(PAPPS_VERSION)/g' \ - -e 's/$$(VERSION)/$(VERSION)/g' \ + sed -e 's/@PORTABLEAPPS_PACKAGE_VERSION@/$(PAPPS_VERSION)/g' \ + -e 's/@VERSION@/$(VERSION)/g' \ < appinfo.tmpl > $@ $(LAUNCHER_INI): dirs $(PROGRAM_PORTABLE).ini diff --git a/packaging/portableapps/appinfo.tmpl b/packaging/portableapps/appinfo.tmpl index ef74ac58fd..9847caadde 100755 --- a/packaging/portableapps/appinfo.tmpl +++ b/packaging/portableapps/appinfo.tmpl @@ -19,8 +19,8 @@ Freeware=true CommercialUse=true [Version] -PackageVersion=$(PAPPS_VERSION) -DisplayVersion=$(VERSION) +PackageVersion=@PORTABLEAPPS_PACKAGE_VERSION@ +DisplayVersion=@VERSION@ [Control] Icons=1 diff --git a/packaging/portableapps/xcopy-deploy-exclude.txt b/packaging/portableapps/xcopy-deploy-exclude.txt new file mode 100644 index 0000000000..034fb88ffa --- /dev/null +++ b/packaging/portableapps/xcopy-deploy-exclude.txt @@ -0,0 +1,2 @@ +.ilk +.pdb -- cgit v1.2.3