aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt7
-rw-r--r--README.adoc2
-rw-r--r--Win32Cleanup.cmake37
3 files changed, 42 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 949b20e..5db2c07 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,5 @@
# The last version with Windows XP support is 3.13, we want to keep that
-cmake_minimum_required (VERSION 3.9)
+cmake_minimum_required (VERSION 3.10)
project (logdiag VERSION 0.2.1 LANGUAGES C)
# Options
@@ -333,8 +333,7 @@ if (WIN32)
install (DIRECTORY
${WIN32_DEPENDS_PATH}/bin/
DESTINATION .
- FILES_MATCHING PATTERN "*.dll"
- PATTERN "libgettext*" EXCLUDE)
+ FILES_MATCHING PATTERN "*.dll")
install (DIRECTORY
${WIN32_DEPENDS_PATH}/etc/
DESTINATION etc)
@@ -366,6 +365,8 @@ if (WIN32)
DESTINATION share/locale)
endif (translation_found GREATER -1)
endforeach (locale)
+
+ install (SCRIPT Win32Cleanup.cmake)
else (WIN32)
install (TARGETS logdiag DESTINATION bin)
install (FILES share/logdiag.desktop DESTINATION share/applications)
diff --git a/README.adoc b/README.adoc
index ab899d8..81c95dc 100644
--- a/README.adoc
+++ b/README.adoc
@@ -15,7 +15,7 @@ a package with the latest development version from Archlinux's AUR.
Requirements
------------
Runtime dependencies: GTK+ >= 3.8, json-glib >= 0.10.4, lua >= 5.2 +
-Build dependencies: CMake >= 3.9
+Build dependencies: CMake >= 3.10
Build from source on Unix-like systems
--------------------------------------
diff --git a/Win32Cleanup.cmake b/Win32Cleanup.cmake
new file mode 100644
index 0000000..be53ef8
--- /dev/null
+++ b/Win32Cleanup.cmake
@@ -0,0 +1,37 @@
+# To be run from cmake_install.cmake, eradicates all unreferenced libraries.
+# CMake 3.9.6 has a parsing bug with ENCODING UTF-8.
+cmake_minimum_required (VERSION 3.10)
+
+# CPack runs this almost without any CMake variables at all
+# (cmStateSnapshot::SetDefaultDefinitions(), CMAKE_INSTALL_PREFIX, [DESTDIR])
+set (installdir "${CMAKE_INSTALL_PREFIX}")
+if (NOT installdir OR installdir MATCHES "^/usr(/|$)")
+ return ()
+endif ()
+
+# The function is recursive and CMake has tragic scoping behaviour;
+# environment variables are truly global there, in the absence of a cache
+unset (ENV{seen})
+function (expand path)
+ set (seen $ENV{seen})
+ if (path IN_LIST seen OR NOT EXISTS "${path}")
+ return ()
+ endif ()
+
+ set (ENV{seen} "$ENV{seen};${path}")
+ file (STRINGS "${path}" strings REGEX "[.][Dd][Ll][Ll]$" ENCODING UTF-8)
+ foreach (string ${strings})
+ string (REGEX MATCH "[-.+_a-zA-Z0-9]+$" word "${string}")
+ expand ("${installdir}/${word}")
+ endforeach ()
+endfunction ()
+
+file (GLOB roots LIST_DIRECTORIES false "${installdir}/*.[Ee][Xx][Ee]"
+ "${installdir}/lib/gdk-pixbuf-2.0/2.10.0/loaders/*.[Dd][Ll][Ll]")
+foreach (binary ${roots})
+ expand ("${binary}")
+endforeach ()
+
+file (GLOB libraries LIST_DIRECTORIES false "${installdir}/*.[Dd][Ll][Ll]")
+list (REMOVE_ITEM libraries $ENV{seen})
+file (REMOVE ${libraries})