Skip to content

Instantly share code, notes, and snippets.

@arthurzam
Created July 30, 2016 06:50
Show Gist options
  • Save arthurzam/fcc76d90b9bb96a21ed5d41453716306 to your computer and use it in GitHub Desktop.
Save arthurzam/fcc76d90b9bb96a21ed5d41453716306 to your computer and use it in GitHub Desktop.
QMPlay2 various patches

QMPlay2-0001-Cpack.patch - cpack patch

QMPlay2-0001-Finding-Depends.patch - v1 of finding dll depends QMPlay2-0001-Finding-Depends_v2.patch - v2 of finding dll depends

From 977d56505964896e696d406d4af8c8e747989ef2 Mon Sep 17 00:00:00 2001
From: Zamarin Arthur <arthurzam@gmail.com>
Date: Sat, 2 Jul 2016 17:01:46 +0300
Subject: [PATCH] CPack
* global variables
---
CMakeLists.txt | 6 ++++++
src/cmake/Modules/MyCPackConfig.cmake | 19 +++++++++++++++++++
2 files changed, 25 insertions(+)
create mode 100644 src/cmake/Modules/MyCPackConfig.cmake
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 388bad8..08dd49b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -162,6 +162,10 @@ if(NOT WIN32)
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/version
OUTPUT_VARIABLE QMPLAY2_VERSION)
string(STRIP ${QMPLAY2_VERSION} QMPLAY2_VERSION)
+
+ string(REGEX REPLACE "^([0-9]+)\\.([0-9]+)\\.([0-9]+)$" "\\1" QMPLAY2_VERSION_MAJOR "${QMPLAY2_VERSION}")
+ string(REGEX REPLACE "^([0-9]+)\\.([0-9]+)\\.([0-9]+)$" "\\2" QMPLAY2_VERSION_MINOR "${QMPLAY2_VERSION}")
+ string(REGEX REPLACE "^([0-9]+)\\.([0-9]+)\\.([0-9]+)$" "\\3" QMPLAY2_VERSION_PATCH "${QMPLAY2_VERSION}")
endif()
if(USE_QT5)
@@ -274,3 +278,5 @@ message(STATUS "")
PRINT_ENABLED_FEATURES()
PRINT_DISABLED_FEATURES()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
+
+include(MyCPackConfig)
diff --git a/src/cmake/Modules/MyCPackConfig.cmake b/src/cmake/Modules/MyCPackConfig.cmake
new file mode 100644
index 0000000..7c8e3a0
--- /dev/null
+++ b/src/cmake/Modules/MyCPackConfig.cmake
@@ -0,0 +1,19 @@
+set(CPACK_PACKAGE_NAME "QMPlay2")
+set(CPACK_PACKAGE_VENDOR "Błażej Szczygieł") # TODO: is proper vendor?
+set(CPACK_PACKAGE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/cpack")
+set(CPACK_PACKAGE_INSTALL_DIRECTORY "QMPlay2")
+set(CPACK_PACKAGE_VERSION_MAJOR ${QMPLAY2_VERSION_MAJOR})
+set(CPACK_PACKAGE_VERSION_MINOR ${QMPLAY2_VERSION_MINOR})
+set(CPACK_PACKAGE_VERSION_PATCH ${QMPLAY2_VERSION_PATCH})
+set(CPACK_PACKAGE_CONTACT "spaz16@wp.pl")
+set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Video and Audio Player which can Play most Formats and Codecs")
+set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
+set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
+set(CPACK_PACKAGE_EXECUTABLES "QMPlay2;QMPlay2")
+set(CPACK_STRIP_FILES ON)
+
+# TODO: NSIS
+
+# TODO: Bundle
+
+include(CPack)
--
2.9.2
From 0bd96889c89b20e67adcfde3abc5400c959acb39 Mon Sep 17 00:00:00 2001
From: Zamarin Arthur <arthurzam@gmail.com>
Date: Mon, 4 Jul 2016 14:21:09 +0300
Subject: [PATCH] Finding Depends
problem with finding depends on cross-compile (can't find the dlls).
---
CMakeLists.txt | 9 +++++++++
src/CMakeLists.txt | 11 +++++++++++
src/cmake/Dependencies.cmake.in | 28 ++++++++++++++++++++++++++++
src/gui/Windows/depends.sh | 19 +++++++++++++++++++
src/qmplay2/CMakeLists.txt | 1 +
5 files changed, 68 insertions(+)
create mode 100644 src/cmake/Dependencies.cmake.in
create mode 100755 src/gui/Windows/depends.sh
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 920f506..772a8a0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -272,6 +272,15 @@ configure_file(
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
+file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/binary_files_manifest.txt"
+ CONTENT ${binary_list})
+configure_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/src/cmake/Dependencies.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/cmake_dependencies.cmake"
+ @ONLY
+ )
+INSTALL(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/cmake_dependencies.cmake")
+
message(STATUS "")
PRINT_ENABLED_FEATURES()
PRINT_DISABLED_FEATURES()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index db03b61..96a0e08 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -9,6 +9,17 @@ if(COMMAND cmake_policy)
endif()
endif()
+set(binary_list "" CACHE INTERNAL "binary list")
+
+function(add_target_binary name)
+ if(CMAKE_VERSION VERSION_LESS 2.8.11)
+ get_target_property(BINARY_LOC ${name} LOCATION)
+ else()
+ set(BINARY_LOC $<TARGET_FILE:${name}>)
+ endif()
+ set(binary_list ${binary_list} "${BINARY_LOC}" CACHE INTERNAL "binary list")
+endfunction()
+
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
diff --git a/src/cmake/Dependencies.cmake.in b/src/cmake/Dependencies.cmake.in
new file mode 100644
index 0000000..b07a395
--- /dev/null
+++ b/src/cmake/Dependencies.cmake.in
@@ -0,0 +1,28 @@
+# should be ran during install
+
+if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/binary_files_manifest.txt")
+ message(FATAL_ERROR "Cannot find binary files manifest: @CMAKE_CURRENT_BINARY_DIR@/binary_files_manifest.txt")
+endif()
+
+set(WIN32 @WIN32@)
+set(UNIX @UNIX@)
+set(APPLE @APPLE@)
+
+include(GetPrerequisites)
+
+file(READ "@CMAKE_CURRENT_BINARY_DIR@/binary_files_manifest.txt" files)
+string(REGEX REPLACE "\n" ";" files "${files}")
+foreach(file ${files})
+ message("============ ${file}")
+ get_prerequisites("${file}" DEPENDENCIES 1 0 "" $ENV{PATH})
+ message("============ ${DEPENDENCIES}")
+ foreach(DEPENDENCY ${DEPENDENCIES})
+ if(IS_ABSOLUTE DEPENDENCY)
+ get_filename_component(DEPENDENCY_NAME "${DEPENDENCY}" NAME)
+ get_filename_component(DEPENDENCY_ACTUAL "${DEPENDENCY}" REALPATH)
+ message("******** depends: ${DEPENDENCY_ACTUAL} -> ${DEPENDENCY_NAME}")
+ else()
+ message("could not found ${DEPENDENCY}")
+ endif()
+ endforeach()
+endforeach()
diff --git a/src/gui/Windows/depends.sh b/src/gui/Windows/depends.sh
new file mode 100755
index 0000000..f4e3d85
--- /dev/null
+++ b/src/gui/Windows/depends.sh
@@ -0,0 +1,19 @@
+_output="$1"
+
+find_dep() {
+ objdump -p $1 | grep -e "DLL N" |
+ sort -u | sed -r 's|^.* (.*\.dll)|\1|' | grep -ve "^[A-Z0-9]*.dll$" | \
+ while read dll; do
+ _dll_path=$(find ${PATH//:/ } -maxdepth 1 -name "$dll" | head -1)
+ if ! grep -qe "$_dll_path" "$_output"; then
+ echo "$_dll_path" >> $_output
+ find_dep "$_dll_path"
+ fi
+ done
+}
+
+find src/ -name "*.dll" -o -name "*.exe" | while read file; do
+ find_dep $file
+ done
+
+cat "$1"
diff --git a/src/qmplay2/CMakeLists.txt b/src/qmplay2/CMakeLists.txt
index be07c35..3bd9022 100644
--- a/src/qmplay2/CMakeLists.txt
+++ b/src/qmplay2/CMakeLists.txt
@@ -148,6 +148,7 @@ add_library(${PROJECT_NAME} SHARED
${QMPLAY2_SRC}
${QMPLAY2_RESOURCES_RCC}
)
+add_target_binary(${PROJECT_NAME})
if(USE_QT5)
qt5_use_modules(${PROJECT_NAME} Gui Widgets)
--
2.9.0
From 19e7601102d34002dbd148d359164de3bd4de9da Mon Sep 17 00:00:00 2001
From: Zamarin Arthur <arthurzam@gmail.com>
Date: Mon, 4 Jul 2016 14:19:30 +0300
Subject: [PATCH] Another version
---
CMakeLists.txt | 2 +-
src/CMakeLists.txt | 26 +++
src/cmake/Modules/DeployQt5.cmake | 391 ++++++++++++++++++++++++++++++++++++++
src/gui/Windows/depends.sh | 19 ++
src/qmplay2/CMakeLists.txt | 2 +
5 files changed, 439 insertions(+), 1 deletion(-)
create mode 100644 src/cmake/Modules/DeployQt5.cmake
create mode 100755 src/gui/Windows/depends.sh
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b10129a..f892828 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -196,7 +196,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang
set(CMAKE_CXX_FLAGS_MINSIZEREL "-fno-exceptions -g0 ${CMAKE_CXX_FLAGS_MINSIZEREL}")
# disable deprecated declarations warnings for Release build
- if(NOT CMAKE_BUILD_TYPE MATCHES "Deb")
+ if(NOT CMAKE_BUILD_TYPE MATCHES "^[Dd][Ee][Bb][Uu][Gg]")
set(CMAKE_CXX_FLAGS "-Wno-deprecated-declarations ${CMAKE_CXX_FLAGS}")
endif()
# enable warnings
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index db03b61..4313df5 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -12,6 +12,32 @@ endif()
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
+if(APPLE OR WIN32)
+ if(USE_QT5)
+ include(DeployQt5)
+ else()
+ include(DeployQt4)
+ endif()
+endif()
+
+macro(deploy_binary target_name libs)
+ message(${CMAKE_CURRENT_BINARY_DIR})
+ if(APPLE OR WIN32)
+ if(CMAKE_VERSION VERSION_LESS 2.8.11)
+ get_target_property(target_loc ${target_name} LOCATION)
+ else()
+ set(target_loc $<TARGET_FILE:${target_name}>)
+ endif()
+
+ if(USE_QT5)
+ FIXUP_QT5_EXECUTABLE(${target_name} "" ) # "" "${libs}" "" "" ""
+ #install_qt5_executable(${target_loc} "" "" "" "")
+ else()
+ install_qt4_executable(${target_loc} "${plugins}" "${ob_plugins}" "${dirs}" "")
+ endif()
+ endif()
+endmacro()
+
add_subdirectory(qmplay2)
if(CMAKE_VERSION VERSION_LESS 2.8.11)
get_target_property(libqmplay2 qmplay2 LOCATION)
diff --git a/src/cmake/Modules/DeployQt5.cmake b/src/cmake/Modules/DeployQt5.cmake
new file mode 100644
index 0000000..35538fd
--- /dev/null
+++ b/src/cmake/Modules/DeployQt5.cmake
@@ -0,0 +1,391 @@
+# - Functions to help assemble a standalone Qt5 executable.
+# A collection of CMake utility functions useful for deploying
+# Qt5 executables.
+#
+# The following functions are provided by this module:
+# write_qt5_conf
+# resolve_qt5_paths
+# fixup_qt5_executable
+# install_qt5_plugin_path
+# install_qt5_plugin
+# install_qt5_executable
+# Requires CMake 2.6 or greater because it uses function and
+# PARENT_SCOPE. Also depends on BundleUtilities.cmake.
+#
+# WRITE_QT5_CONF(<qt_conf_dir> <qt_conf_contents>)
+# Writes a qt.conf file with the <qt_conf_contents> into <qt_conf_dir>.
+#
+# RESOLVE_QT5_PATHS(<paths_var> [<executable_path>])
+# Loop through <paths_var> list and if any don't exist resolve them
+# relative to the <executable_path> (if supplied) or the CMAKE_INSTALL_PREFIX.
+#
+# FIXUP_QT5_EXECUTABLE(<executable> [<qtplugins> <libs> <dirs> <plugins_dir> <request_qt_conf>])
+# Copies Qt plugins, writes a Qt configuration file (if needed) and fixes up a
+# Qt5 executable using BundleUtilities so it is standalone and can be
+# drag-and-drop copied to another machine as long as all of the system
+# libraries are compatible.
+#
+# <executable> should point to the executable to be fixed-up.
+#
+# <qtplugins> should contain a list of the names or paths of any Qt plugins
+# to be installed.
+#
+# <libs> will be passed to BundleUtilities and should be a list of any already
+# installed plugins, libraries or executables to also be fixed-up.
+#
+# <dirs> will be passed to BundleUtilities and should contain and directories
+# to be searched to find library dependencies.
+#
+# <plugins_dir> allows an custom plugins directory to be used.
+#
+# <request_qt_conf> will force a qt.conf file to be written even if not needed.
+#
+# INSTALL_QT5_PLUGIN_PATH(plugin executable copy installed_plugin_path_var <plugins_dir> <component> <configurations>)
+# Install (or copy) a resolved <plugin> to the default plugins directory
+# (or <plugins_dir>) relative to <executable> and store the result in
+# <installed_plugin_path_var>.
+#
+# If <copy> is set to TRUE then the plugins will be copied rather than
+# installed. This is to allow this module to be used at CMake time rather than
+# install time.
+#
+# If <component> is set then anything installed will use this COMPONENT.
+#
+# INSTALL_QT5_PLUGIN(plugin executable copy installed_plugin_path_var <plugins_dir> <component>)
+# Install (or copy) an unresolved <plugin> to the default plugins directory
+# (or <plugins_dir>) relative to <executable> and store the result in
+# <installed_plugin_path_var>. See documentation of INSTALL_QT5_PLUGIN_PATH.
+#
+# INSTALL_QT5_EXECUTABLE(<executable> [<qtplugins> <libs> <dirs> <plugins_dir> <request_qt_conf> <component>])
+# Installs Qt plugins, writes a Qt configuration file (if needed) and fixes up
+# a Qt5 executable using BundleUtilities so it is standalone and can be
+# drag-and-drop copied to another machine as long as all of the system
+# libraries are compatible. The executable will be fixed-up at install time.
+# <component> is the COMPONENT used for bundle fixup and plugin installation.
+# See documentation of FIXUP_QT5_BUNDLE.
+
+#=============================================================================
+# Copyright 2011 Mike McQuaid <m...@mikemcquaid.com>
+# Copyright 2013 Mihai Moldovan <io...@ionic.de>
+# CMake - Cross Platform Makefile Generator
+# Copyright 2000-2011 Kitware, Inc., Insight Software Consortium
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# * Neither the names of Kitware, Inc., the Insight Software Consortium,
+# nor the names of their contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# The functions defined in this file depend on the fixup_bundle function
+# (and others) found in BundleUtilities.cmake
+
+include(BundleUtilities)
+set(DeployQt5_cmake_dir "${CMAKE_CURRENT_LIST_DIR}")
+set(DeployQt5_apple_plugins_dir "PlugIns")
+
+function(write_qt5_conf qt_conf_dir qt_conf_contents)
+ set(qt_conf_path "${qt_conf_dir}/qt.conf")
+ message(STATUS "Writing ${qt_conf_path}")
+ file(WRITE "${qt_conf_path}" "${qt_conf_contents}")
+endfunction()
+
+function(resolve_qt5_paths paths_var)
+ set(executable_path ${ARGV1})
+
+ set(paths_resolved)
+ foreach(path ${${paths_var}})
+ if(EXISTS "${path}")
+ list(APPEND paths_resolved "${path}")
+ else()
+ if(${executable_path})
+ list(APPEND paths_resolved
+"${executable_path}/${path}")
+ else()
+ list(APPEND paths_resolved
+"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${path}")
+ endif()
+ endif()
+ endforeach()
+ set(${paths_var} ${paths_resolved} PARENT_SCOPE)
+endfunction()
+
+function(fixup_qt5_executable executable)
+ set(qtplugins ${ARGV1})
+ set(libs ${ARGV2})
+ set(dirs ${ARGV3})
+ set(plugins_dir ${ARGV4})
+ set(request_qt_conf ${ARGV5})
+
+ message(STATUS "fixup_qt5_executable")
+ message(STATUS " executable='${executable}'")
+ message(STATUS " qtplugins='${qtplugins}'")
+ message(STATUS " libs='${libs}'")
+ message(STATUS " dirs='${dirs}'")
+ message(STATUS " plugins_dir='${plugins_dir}'")
+ message(STATUS " request_qt_conf='${request_qt_conf}'")
+
+ if(QT_LIBRARY_DIR)
+ list(APPEND dirs "${QT_LIBRARY_DIR}")
+ endif()
+ if(QT_BINARY_DIR)
+ list(APPEND dirs "${QT_BINARY_DIR}")
+ endif()
+
+ if(APPLE)
+ set(qt_conf_dir "${executable}/Contents/Resources")
+ set(executable_path "${executable}")
+ set(write_qt_conf TRUE)
+ if(NOT plugins_dir)
+ set(plugins_dir "${DeployQt5_apple_plugins_dir}")
+ endif()
+ else()
+ get_filename_component(executable_path "${executable}" PATH)
+ if(NOT executable_path)
+ set(executable_path ".")
+ endif()
+ set(qt_conf_dir "${executable_path}")
+ set(write_qt_conf ${request_qt_conf})
+ endif()
+
+ foreach(plugin ${qtplugins})
+ set(installed_plugin_path "")
+ install_qt5_plugin("${plugin}" "${executable}" 1
+installed_plugin_path)
+ list(APPEND libs ${installed_plugin_path})
+ endforeach()
+
+ foreach(lib ${libs})
+ if(NOT EXISTS "${lib}")
+ message(FATAL_ERROR "Library does not exist: ${lib}")
+ endif()
+ endforeach()
+
+ resolve_qt5_paths(libs "${executable_path}")
+
+ if(write_qt_conf)
+ set(qt_conf_contents "[Paths]\nPlugins = ${plugins_dir}")
+ write_qt5_conf("${qt_conf_dir}" "${qt_conf_contents}")
+ endif()
+
+ fixup_bundle("${executable}" "${libs}" "${dirs}")
+endfunction()
+
+function(install_qt5_plugin_path plugin executable copy
+installed_plugin_path_var)
+ set(plugins_dir ${ARGV4})
+ set(component ${ARGV5})
+ set(configurations ${ARGV6})
+ if(EXISTS "${plugin}")
+ if(APPLE)
+ if(NOT plugins_dir)
+ set(plugins_dir
+"${DeployQt5_apple_plugins_dir}")
+ endif()
+ set(plugins_path
+"${executable}/Contents/${plugins_dir}")
+ else()
+ get_filename_component(plugins_path "${executable}"
+PATH)
+ if(NOT plugins_path)
+ set(plugins_path ".")
+ endif()
+ if(plugins_dir)
+ set(plugins_path
+"${plugins_path}/${plugins_dir}")
+ endif()
+ endif()
+
+ set(plugin_group "")
+
+ get_filename_component(plugin_path "${plugin}" PATH)
+ get_filename_component(plugin_parent_path "${plugin_path}" PATH)
+ get_filename_component(plugin_parent_dir_name
+"${plugin_parent_path}" NAME)
+ get_filename_component(plugin_name "${plugin}" NAME)
+ string(TOLOWER "${plugin_parent_dir_name}"
+plugin_parent_dir_name)
+
+ if("${plugin_parent_dir_name}" STREQUAL "plugins")
+ get_filename_component(plugin_group "${plugin_path}"
+NAME)
+ set(${plugin_group_var} "${plugin_group}")
+ endif()
+ set(plugins_path "${plugins_path}/${plugin_group}")
+
+ if(${copy})
+ file(MAKE_DIRECTORY "${plugins_path}")
+ file(COPY "${plugin}" DESTINATION "${plugins_path}")
+ else()
+ if(configurations AND (CMAKE_CONFIGURATION_TYPES OR
+CMAKE_BUILD_TYPE))
+ set(configurations CONFIGURATIONS
+${configurations})
+ else()
+ unset(configurations)
+ endif()
+ install(FILES "${plugin}" DESTINATION "${plugins_path}"
+${configurations} ${component})
+ endif()
+ set(${installed_plugin_path_var}
+"${plugins_path}/${plugin_name}" PARENT_SCOPE)
+ endif()
+endfunction()
+
+function(install_qt5_plugin plugin executable copy installed_plugin_path_var)
+ set(plugins_dir ${ARGV4})
+ set(component ${ARGV5})
+ if(EXISTS "${plugin}")
+ install_qt5_plugin_path("${plugin}" "${executable}" "${copy}"
+"${installed_plugin_path_var}" "${plugins_dir}" "${component}")
+ else()
+ #string(TOUPPER "QT_${plugin}_PLUGIN" plugin_var)
+ set(plugin_release)
+ set(plugin_debug)
+ set(plugin_tmp_path)
+ set(plugin_find_path "${Qt5Core_DIR}/../../../plugins/")
+ get_filename_component(plugin_find_path "${plugin_find_path}"
+REALPATH)
+ if(COMMAND cmake_policy)
+ CMAKE_POLICY(SET CMP0009 NEW)
+ #CMAKE_POLICY(SET CMP0011 NEW) # disabling a warning about policy changing in this scope
+ endif(COMMAND cmake_policy)
+
+ if (APPLE)
+ set(plugin_find_release_filename "lib${plugin}.dylib")
+ set(plugin_find_debug_filename "lib${plugin}_debug.dylib")
+ file(GLOB_RECURSE pluginlist "${plugin_find_path}" "${plugin_find_path}/*/lib*.dylib")
+ endif()
+ if(WIN32)
+ set(plugin_find_release_filename "${plugin}.dll")
+ set(plugin_find_debug_filename "${plugin}d.dll")
+ file(GLOB_RECURSE pluginlist "${plugin_find_path}" "${plugin_find_path}/*/*.dll")
+ endif(WIN32)
+ foreach(found_plugin ${pluginlist})
+ get_filename_component(curname "${found_plugin}" NAME)
+ if("${curname}" STREQUAL "${plugin_find_release_filename}")
+ set(plugin_tmp_release_path "${found_plugin}")
+ endif()
+ if("${curname}" STREQUAL "${plugin_find_debug_filename}")
+ set(plugin_tmp_debug_path "${found_plugin}")
+ endif()
+ endforeach()
+
+ if((NOT DEFINED plugin_tmp_release_path OR NOT EXISTS
+"${plugin_tmp_release_path}") AND (NOT DEFINED plugin_tmp_debug_PATH OR NOT
+EXISTS "${plugin_tmp_debug_path}"))
+ message(WARNING "Qt plugin \"${plugin}\" not recognized
+or found.")
+ endif()
+
+ if(EXISTS "${plugin_tmp_release_path}")
+ set(plugin_release "${plugin_tmp_release_path}")
+ elseif(EXISTS "${plugin_tmp_debug_path}")
+ set(plugin_release "${plugin_tmp_debug_path}")
+ endif()
+
+ if(EXISTS "${plugin_tmp_debug_path}")
+ set(plugin_debug "${plugin_tmp_debug_path}")
+ elseif(EXISTS "${plugin_tmp_release_path}")
+ set(plugin_debug "${plugin_tmp_release_path}")
+ endif()
+
+ if(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
+ install_qt5_plugin_path("${plugin_release}"
+"${executable}" "${copy}" "${installed_plugin_path_var}_release"
+"${plugins_dir}" "${component}" "Release|RelWithDebInfo|MinSizeRel")
+ install_qt5_plugin_path("${plugin_debug}"
+"${executable}" "${copy}" "${installed_plugin_path_var}_debug" "${plugins_dir}"
+"${component}" "Debug")
+
+ if(CMAKE_BUILD_TYPE MATCHES "^Debug$")
+ set(${installed_plugin_path_var}
+${${installed_plugin_path_var}_debug})
+ else()
+ set(${installed_plugin_path_var}
+${${installed_plugin_path_var}_release})
+ endif()
+ else()
+ install_qt5_plugin_path("${plugin_release}"
+"${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}"
+"${component}")
+ endif()
+ endif()
+ set(${installed_plugin_path_var} ${${installed_plugin_path_var}}
+PARENT_SCOPE)
+endfunction()
+
+function(install_qt5_executable executable)
+ set(qtplugins ${ARGV1})
+ set(libs ${ARGV2})
+ set(dirs ${ARGV3})
+ set(plugins_dir ${ARGV4})
+ set(request_qt_conf ${ARGV5})
+ set(component ${ARGV6})
+ if(QT_LIBRARY_DIR)
+ list(APPEND dirs "${QT_LIBRARY_DIR}")
+ endif()
+ if(QT_BINARY_DIR)
+ list(APPEND dirs "${QT_BINARY_DIR}")
+ endif()
+ if(component)
+ set(component COMPONENT ${component})
+ else()
+ unset(component)
+ endif()
+
+ get_filename_component(executable_absolute "${executable}" ABSOLUTE)
+ if(EXISTS "${QT_QTCORE_LIBRARY_RELEASE}")
+ gp_file_type("${executable_absolute}"
+"${QT_QTCORE_LIBRARY_RELEASE}" qtcore_type)
+ elseif(EXISTS "${QT_QTCORE_LIBRARY_DEBUG}")
+ gp_file_type("${executable_absolute}" "${QT_QTCORE_LIBRARY_DEBUG}"
+qtcore_type)
+ endif()
+ if(qtcore_type STREQUAL "system")
+ set(qt_plugins_dir "")
+ endif()
+
+ if(QT_IS_STATIC)
+ message(WARNING "Qt built statically: not installing plugins.")
+ else()
+ foreach(plugin ${qtplugins})
+ set(installed_plugin_paths "")
+ install_qt5_plugin("${plugin}" "${executable}" 0
+installed_plugin_paths "${plugins_dir}" "${component}")
+ list(APPEND libs ${installed_plugin_paths})
+ endforeach()
+ endif()
+
+ resolve_qt5_paths(libs "")
+
+ install(CODE
+ "include(\"${DeployQt5_cmake_dir}/DeployQt5.cmake\")
+ set(BU_CHMOD_BUNDLE_ITEMS TRUE)
+ FIXUP_QT5_EXECUTABLE(\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${executable}\"
+\"\" \"${libs}\" \"${dirs}\" \"${plugins_dir}\" \"${request_qt_conf}\")"
+ ${component}
+ )
+endfunction()
diff --git a/src/gui/Windows/depends.sh b/src/gui/Windows/depends.sh
new file mode 100755
index 0000000..f4e3d85
--- /dev/null
+++ b/src/gui/Windows/depends.sh
@@ -0,0 +1,19 @@
+_output="$1"
+
+find_dep() {
+ objdump -p $1 | grep -e "DLL N" |
+ sort -u | sed -r 's|^.* (.*\.dll)|\1|' | grep -ve "^[A-Z0-9]*.dll$" | \
+ while read dll; do
+ _dll_path=$(find ${PATH//:/ } -maxdepth 1 -name "$dll" | head -1)
+ if ! grep -qe "$_dll_path" "$_output"; then
+ echo "$_dll_path" >> $_output
+ find_dep "$_dll_path"
+ fi
+ done
+}
+
+find src/ -name "*.dll" -o -name "*.exe" | while read file; do
+ find_dep $file
+ done
+
+cat "$1"
diff --git a/src/qmplay2/CMakeLists.txt b/src/qmplay2/CMakeLists.txt
index be07c35..b8cce60 100644
--- a/src/qmplay2/CMakeLists.txt
+++ b/src/qmplay2/CMakeLists.txt
@@ -181,3 +181,5 @@ else()
endif()
target_link_libraries(${PROJECT_NAME} ${LIBQMPLAY2_LIBS})
+
+deploy_binary("${PROJECT_NAME}" "${LIBQMPLAY2_LIBS}")
--
2.9.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment