Compare commits

...

2 Commits

Author SHA1 Message Date
3a087ad581
Remove unnecessary DLLs from Windows builds
This saves 20 MiB and 4 MiB of libraries in MSYS2 and bundle
builds respectively, in total, without any adverse effects.

The MSYS2 build remains bloated, due to the Adwaita icon theme.

Bump minimum CMake version to avoid a bug.
2021-10-23 18:01:30 +02:00
4305c603e9
CMakeLists.txt: clean-up
Use the newer 3.0 string quoting to save some ugly escaping.
2021-10-23 16:35:36 +02:00
3 changed files with 58 additions and 16 deletions

View File

@ -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)
@ -379,11 +380,11 @@ endif (WIN32)
install (DIRECTORY share/gui share/library DESTINATION share/${PROJECT_NAME})
install (FILES ${GSETTINGS_SCHEMAS} DESTINATION share/glib-2.0/schemas)
install (CODE " # DESTDIR is not in use on Windows
install (CODE " # DESTDIR is not in use on Windows (WIN32 is only native here!)
if (WIN32 OR \"\$ENV{DESTDIR}\" STREQUAL \"\")
execute_process (COMMAND \"${GLIB_COMPILE_SCHEMAS_EXECUTABLE}\"
\"\${CMAKE_INSTALL_PREFIX}/share/glib-2.0/schemas\")
endif (WIN32 OR \"\$ENV{DESTDIR}\" STREQUAL \"\")")
endif ()")
# CPack
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Schematic editor")
@ -409,19 +410,23 @@ set (CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${PROJECT_NAME}")
set (CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/share\\\\header.bmp")
set (CPACK_NSIS_INSTALLED_ICON_NAME "logdiag.exe")
set (CPACK_NSIS_CREATE_ICONS_EXTRA "
CreateShortCut '\$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\logdiag.lnk' '\$INSTDIR\\\\logdiag.exe'")
set (CPACK_NSIS_DELETE_ICONS_EXTRA "
Delete '\$SMPROGRAMS\\\\$MUI_TEMP\\\\logdiag.lnk'")
set (CPACK_NSIS_EXTRA_INSTALL_COMMANDS "
set (CPACK_NSIS_CREATE_ICONS_EXTRA [[
CreateShortCut '$SMPROGRAMS\\$STARTMENU_FOLDER\\logdiag.lnk' '$INSTDIR\\logdiag.exe'
]])
set (CPACK_NSIS_DELETE_ICONS_EXTRA [[
Delete '$SMPROGRAMS\\$MUI_TEMP\\logdiag.lnk'
]])
set (CPACK_NSIS_EXTRA_INSTALL_COMMANDS [[
WriteRegStr HKCR '.ldd' '' 'logdiag.Diagram'
WriteRegStr HKCR 'logdiag.Diagram' '' 'logdiag Diagram'
WriteRegStr HKCR 'logdiag.Diagram\\\\shell\\\\open\\\\command' '' '\\\"\$INSTDIR\\\\logdiag.exe\\\" \\\"%1\\\"'
WriteRegStr HKCR 'logdiag.Diagram\\\\shell\\\\edit\\\\command' '' '\\\"\$INSTDIR\\\\logdiag.exe\\\" \\\"%1\\\"'
System::Call 'shell32::SHChangeNotify(i,i,i,i) (0x08000000, 0x1000, 0, 0)'")
set (CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "
WriteRegStr HKCR 'logdiag.Diagram\\shell\\open\\command' '' '\"$INSTDIR\\logdiag.exe\" \"%1\"'
WriteRegStr HKCR 'logdiag.Diagram\\shell\\edit\\command' '' '\"$INSTDIR\\logdiag.exe\" \"%1\"'
System::Call 'shell32::SHChangeNotify(i,i,i,i) (0x08000000, 0x1000, 0, 0)'
]])
set (CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS [[
DeleteRegKey HKCR 'logdiag.Diagram'
System::Call 'shell32::SHChangeNotify(i,i,i,i) (0x08000000, 0x1000, 0, 0)'")
System::Call 'shell32::SHChangeNotify(i,i,i,i) (0x08000000, 0x1000, 0, 0)'
]])
string (REPLACE "https://" "https:\\\\\\\\" project_URL_NSIS "${project_URL}")
set (CPACK_NSIS_URL_INFO_ABOUT "${project_URL_NSIS}")

View File

@ -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
--------------------------------------

37
Win32Cleanup.cmake Normal file
View File

@ -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})