From 42333aa353515ccbb68c6e74109cd34a34d1abe6 Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Fri, 4 Dec 2015 09:02:35 -0800 Subject: [PATCH] CMake+PortableApps: Include the VC runtime (second try). Move the code that finds the Visual C++ redistributable DLLs to its own module. Run it before we create our NSIS and PortableApps targets. Add a PortableApps target that copies the redistributable This reverts commit 403fa9fbe0cdba3f443ec4674cda40092525ffe4. Bug: 11800 Change-Id: I081d8fd3f5f37dd590659ca8f2bd309642a9a9df Reviewed-on: https://code.wireshark.org/review/12431 Reviewed-by: Gerald Combs (cherry picked from commit 5b580834aeeee8477039bc099c49c21aeeb3b71f) Reviewed-on: https://code.wireshark.org/review/12432 Petri-Dish: Gerald Combs Tested-by: Petri Dish Buildbot --- CMakeLists.txt | 2 ++ Makefile.am | 1 + cmake/modules/FindMSVC_REDIST.cmake | 23 +++++++++++++++++++++++ cmake/modules/FindNSIS.cmake | 3 --- packaging/nsis/CMakeLists.txt | 12 ------------ packaging/portableapps/CMakeLists.txt | 19 ++++++++++++++++--- 6 files changed, 42 insertions(+), 18 deletions(-) create mode 100644 cmake/modules/FindMSVC_REDIST.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 13d4a8380f..1f3b007698 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2281,6 +2281,8 @@ if(BUILD_dumpcap AND PCAP_FOUND) endif() if (WIN32) + find_package( MSVC_REDIST ) + # Must come after executable targets are defined. find_package( NSIS ) diff --git a/Makefile.am b/Makefile.am index 4f5544b0f7..d104ea18cb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1328,6 +1328,7 @@ EXTRA_DIST = \ cmake/modules/FindLUA.cmake \ cmake/modules/FindLYNX.cmake \ cmake/modules/FindM.cmake \ + cmake/modules/FindMSVC_REDIST.cmake \ cmake/modules/FindNL.cmake \ cmake/modules/FindNSIS.cmake \ cmake/modules/FindOS_X_FRAMEWORKS.cmake \ diff --git a/cmake/modules/FindMSVC_REDIST.cmake b/cmake/modules/FindMSVC_REDIST.cmake new file mode 100644 index 0000000000..2d1237b37d --- /dev/null +++ b/cmake/modules/FindMSVC_REDIST.cmake @@ -0,0 +1,23 @@ +# +# Find the Microsoft Visual C++ library DLLs. +# These are included with the full frontal (Professional, Enterprise) editions +# of Visual Studio but not Express. +# +# MSVCR_DLL - Path to the redistributable DLLs. +# + +set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE) +include(InstallRequiredSystemLibraries) + +# CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS will likely give us a list of DLL +# paths containing spaces. We'll assume that they're all in the same +# directory and use it to create something that's easier to pass to +# NSIS. + +set(MSVCR_DLL) +list(GET CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS 0 _msvcr_dll) +if(_msvcr_dll) + get_filename_component(_msvcr_dir ${_msvcr_dll} DIRECTORY) + set(MSVCR_DLL "${_msvcr_dir}/*.*") + file(TO_NATIVE_PATH "${MSVCR_DLL}" MSVCR_DLL) +endif() diff --git a/cmake/modules/FindNSIS.cmake b/cmake/modules/FindNSIS.cmake index 250104c274..5429ac681b 100644 --- a/cmake/modules/FindNSIS.cmake +++ b/cmake/modules/FindNSIS.cmake @@ -10,6 +10,3 @@ find_program(MAKENSIS_EXECUTABLE makensis PATH "$ENV{PROGRAMFILES}/NSIS" "$ENV{PROGRAMW6432}/NSIS" DOC "Path to the makensis utility." ) - -set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE) -include(InstallRequiredSystemLibraries) diff --git a/packaging/nsis/CMakeLists.txt b/packaging/nsis/CMakeLists.txt index 564f719f12..89d73a518d 100644 --- a/packaging/nsis/CMakeLists.txt +++ b/packaging/nsis/CMakeLists.txt @@ -102,18 +102,6 @@ if(BUILD_wireshark_gtk AND GTK_FOUND) set (GTK_DIR "\${STAGING_DIR}") endif() -# CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS will likely give us a list of DLL -# paths containing spaces. We'll assume that they're all in the same -# directory and use it to create something that's easier to pass to -# NSIS. -set(MSVCR_DLL) -list(GET CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS 0 _msvcr_dll) -if(_msvcr_dll) - get_filename_component(_msvcr_dir ${_msvcr_dll} DIRECTORY) - set(MSVCR_DLL "${_msvcr_dir}/*.*") - file(TO_NATIVE_PATH "${MSVCR_DLL}" MSVCR_DLL) -endif() - # This *should* be compatible with the way we currently do things. if(MSVC12) set(_vcredist_name "vcredist_${TARGET_MACHINE}.exe") diff --git a/packaging/portableapps/CMakeLists.txt b/packaging/portableapps/CMakeLists.txt index 38c428598d..5753d34609 100644 --- a/packaging/portableapps/CMakeLists.txt +++ b/packaging/portableapps/CMakeLists.txt @@ -21,7 +21,6 @@ # 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) @@ -46,6 +45,7 @@ macro( ADD_PORTABLEAPPS_PACKAGE_TARGET ) 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 @@ -53,16 +53,29 @@ macro( ADD_PORTABLEAPPS_PACKAGE_TARGET ) 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") + if(MSVCR_DLL) + add_custom_target(portableapps_runtime + COMMAND xcopy "${MSVCR_DLL}" ${_portableapps_app_dir_native} /D /I /Y + ) + else(MSVCR_DLL) + add_custom_target(portableapps_runtime + COMMAND ${CMAKE_COMMAND} -E echo "C Runtime MUST be installed on target system." + ) + endif(MSVCR_DLL) + + set_target_properties(portableapps_runtime PROPERTIES FOLDER "Packaging") + add_dependencies(portableapps_runtime portableapps_app_dir) + # Build the PortableApps package. # nsis_package_prep must be built prior to this. set (_portableapps_package ${CMAKE_BINARY_DIR}/packaging/portableapps/WiresharkPortable_$(VERSION).exe) add_custom_target(portableapps_package DEPENDS - portableapps_app_dir + portableapps_runtime ${_portableapps_package} ) set_target_properties(portableapps_package PROPERTIES FOLDER "Packaging")