[multimedia/kid3] /: CMake 4.4: Fix CMake error file INSTALL given no DESTINATION

Urs Fleisch <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit c28c9d9d6d7ee0fff2b8ece3cd7027bb47833397 by Urs Fleisch.
Committed on 21/07/2026 at 16:06.
Pushed by ufleisch into branch 'master'.

CMake 4.4: Fix CMake error file INSTALL given no DESTINATION

Occurs with CMake 4.4 when building the bundle (ninja package).
CMake 4.4 rejects an empty CMAKE_INSTALL_PREFIX with BUNDLE DESTINATION:

CPack: - Install project: kid3 []
CMake Error at ..kid3/src/app/qt/cmake_install.cmake:45 (file):
  file INSTALL given no DESTINATION

M  +24   -1    CMakeLists.txt
M  +6    -2    build.sh
M  +4    -0    doc/CMakeLists.txt
M  +4    -0    src/app/cli/CMakeLists.txt
M  +14   -0    src/app/qt/CMakeLists.txt
M  +4    -0    src/core/CMakeLists.txt
M  +4    -0    src/gui/CMakeLists.txt
M  +2    -0    translations/CMakeLists.txt

https://invent.kde.org/multimedia/kid3/-/commit/c28c9d9d6d7ee0fff2b8ece3cd7027bb47833397

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3fff0c59..7dee145d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -384,7 +384,6 @@ if(NOT QT_MAJOR_VERSION)
 endif()
 
 if(LINUX_SELF_CONTAINED)
-  set(CPACK_INSTALL_PREFIX "")
   # Avoid GLIBC_2.14 not found errors on older systems like Debian Wheezy.
   # https://stackoverflow.com/questions/8823267/linking-against-older-symbol-version-in-a-so-file
   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -include ${CMAKE_CURRENT_SOURCE_DIR}/linux/glibc_version_nightmare.h")
@@ -552,6 +551,27 @@ if(APPLE AND CMAKE_STRIP)
   set(CMAKE_STRIP "${CMAKE_CURRENT_BINARY_DIR}/strip_silent.sh")
 endif()
 
+# CMake 4.x errors on file(INSTALL DESTINATION "") when prefix is empty.
+# Override an empty CMAKE_INSTALL_PREFIX temporarily, then restore it
+# again with restore_install_prefix().
+macro(replace_empty_install_prefix)
+  install(CODE [[
+    set(_saved_install_prefix "${CMAKE_INSTALL_PREFIX}")
+    if(CMAKE_INSTALL_PREFIX STREQUAL "")
+      set(CMAKE_INSTALL_PREFIX "/.")
+    endif()
+  ]])
+endmacro()
+
+# Restore temporary replacement of CMAKE_INSTALL_PREFIX made by
+# replace_empty_install_prefix().
+macro(restore_install_prefix)
+  install(CODE [[
+    set(CMAKE_INSTALL_PREFIX "${_saved_install_prefix}")
+    unset(_saved_install_prefix)
+  ]])
+endmacro()
+
 add_subdirectory(src)
 
 if(WITH_DOC)
@@ -577,6 +597,7 @@ endif()
 
 # To create a package, run cpack
 if(APPLE)
+  set(CPACK_INSTALL_PREFIX "")
   if(CMAKE_HOST_APPLE)
     install(SCRIPT ${CMAKE_SOURCE_DIR}/macosx/mac-codesign.cmake)
     # KDE's appleutils.getDmgApplicationId() searches for the Info.plist file
@@ -587,8 +608,10 @@ if(APPLE)
   set(CPACK_BINARY_DRAGNDROP ON)
   set(CPACK_GENERATOR DragNDrop)
 elseif(WIN32)
+  set(CPACK_INSTALL_PREFIX "")
   set(CPACK_GENERATOR ZIP)
 elseif(LINUX_SELF_CONTAINED)
+  set(CPACK_INSTALL_PREFIX "")
   set(CPACK_GENERATOR TGZ)
 else()
   set(CPACK_GENERATOR DEB)
diff --git a/build.sh b/build.sh
index a497824c..ec793c2b 100755
--- a/build.sh
+++ b/build.sh
@@ -2067,8 +2067,12 @@ EOF
       _instdir=kid3-$_version-win32
     fi
     test -d $_instdir && rm -rf $_instdir
-    mkdir -p $_instdir
-    DESTDIR=$(pwd)/$_instdir ninja install/strip
+    rm -f *.zip
+    ninja package
+    _zip=(kid3-*win*.zip)
+    7z x "$_zip" -aoa
+    mv ${_zip%.zip} $_instdir
+    rm -f "$_zip"
 
     _plugin_qt_version=$(grep "Created by.*Qt" src/plugins/musicbrainzimport/moc_musicbrainzimportplugin.cpp)
     _plugin_qt_version=${_plugin_qt_version##* \(Qt }
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index 09704625..e3e41e26 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -167,6 +167,8 @@ foreach(_lang ${_languages})
     set(_dir ${_po_dir}/${_lang}/docs/kid3)
   endif()
 
+  replace_empty_install_prefix()
+
   if(BUILD_KDE_APP)
     kf5_create_handbook(${_dir}/index.docbook ${_lang})
   endif()
@@ -178,4 +180,6 @@ foreach(_lang ${_languages})
   if(UNIX)
     kid3_create_manpage(${_dir}/index.docbook ${_lang})
   endif()
+
+  restore_install_prefix()
 endforeach()
diff --git a/src/app/cli/CMakeLists.txt b/src/app/cli/CMakeLists.txt
index cf16316f..b9916d5b 100644
--- a/src/app/cli/CMakeLists.txt
+++ b/src/app/cli/CMakeLists.txt
@@ -75,10 +75,14 @@ else()
   set(cli_BINDIR ${WITH_BINDIR})
 endif()
 
+replace_empty_install_prefix()
+
 install(TARGETS kid3-cli
   BUNDLE DESTINATION .
   RUNTIME DESTINATION ${cli_BINDIR})
 
+restore_install_prefix()
+
 if(LINUX_SELF_CONTAINED)
   set_target_properties(kid3-cli PROPERTIES INSTALL_RPATH "\$ORIGIN")
 endif()
diff --git a/src/app/qt/CMakeLists.txt b/src/app/qt/CMakeLists.txt
index 98244d93..e81705b5 100644
--- a/src/app/qt/CMakeLists.txt
+++ b/src/app/qt/CMakeLists.txt
@@ -132,10 +132,14 @@ if(APPLE)
   endif()
 endif()
 
+replace_empty_install_prefix()
+
 install(TARGETS ${KID3_EXECUTABLE}
   BUNDLE DESTINATION .
   RUNTIME DESTINATION ${WITH_BINDIR})
 
+restore_install_prefix()
+
 if(LINUX_SELF_CONTAINED)
   # Change RPATH/RUNPATH of executable/library.
   macro(CHANGE_RPATH _rpath _file)
@@ -178,6 +182,8 @@ if(APPLE OR WIN32 OR LINUX_SELF_CONTAINED)
   endif()
   string(REPLACE "/./" "/" bundle_app ${bundle_app})
 
+  replace_empty_install_prefix()
+
   # Install Qt JPEG, WebP and SVG icon plugins
   install(DIRECTORY "${QT_PLUGINS_DIR}/imageformats"
     DESTINATION ${plugin_dest_dir}
@@ -301,6 +307,8 @@ if(APPLE OR WIN32 OR LINUX_SELF_CONTAINED)
     CHANGE_RPATH("\$ORIGIN/.." "${plugin_dest_dir}/xcbglintegrations/libqxcb-glx-integration${CMAKE_SHARED_LIBRARY_SUFFIX}")
   endif()
 
+  restore_install_prefix()
+
   if(CMAKE_CROSSCOMPILING AND NOT APPLE)
     # Avoid error "/usr/bin/ldd failed: 1" from GetPrerequisites.cmake:800
     # when cross-packaging, this does not seem to be supported.
@@ -382,6 +390,8 @@ if(APPLE AND REMOVE_ARCH)
 endif()
 
 if(WIN32)
+  replace_empty_install_prefix()
+
   # Use reduced size ICU libraries, QTBUG-29828, QTBUG-38259.
   # A folder with reduced ICU libraries can be copied to the Qt bin directory.
   get_target_property(_qtBinDir Qt${QT_VERSION_MAJOR}::Core LOCATION)
@@ -410,6 +420,8 @@ if(WIN32)
     install(FILES "${_qtBinDir}/Qt${QT_VERSION_MAJOR}QmlMeta.dll"
             DESTINATION ${WITH_BINDIR})
   endif()
+
+  restore_install_prefix()
 endif()
 
 if(LINUX_SELF_CONTAINED)
@@ -428,6 +440,7 @@ if(LINUX_SELF_CONTAINED)
       endif()
     endif()
   ")
+  replace_empty_install_prefix()
   install(DIRECTORY "${_qtLibDir}/icu_reduced/"
           DESTINATION ${WITH_BINDIR} OPTIONAL)
   # Qt searches for OpenSSL 1.0, which is not found on distributions
@@ -435,4 +448,5 @@ if(LINUX_SELF_CONTAINED)
   install(FILES "${CMAKE_BINARY_DIR}/../buildroot/usr/local/ssl/libssl.so"
                 "${CMAKE_BINARY_DIR}/../buildroot/usr/local/ssl/libcrypto.so"
           DESTINATION ${WITH_BINDIR})
+  restore_install_prefix()
 endif()
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 520de5d9..769bca83 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -195,9 +195,13 @@ if(ANDROID AND QT_VERSION_MAJOR LESS 6)
 endif()
 
 if(BUILD_SHARED_LIBS)
+  replace_empty_install_prefix()
+
   install(TARGETS kid3-core
     LIBRARY DESTINATION ${WITH_LIBDIR}
     RUNTIME DESTINATION ${WITH_BINDIR})
+
+  restore_install_prefix()
 endif()
 
 if(BUILD_KDE_APP)
diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt
index 37692d08..3a128429 100644
--- a/src/gui/CMakeLists.txt
+++ b/src/gui/CMakeLists.txt
@@ -128,7 +128,11 @@ if(HAVE_QTMULTIMEDIA)
 endif()
 
 if(BUILD_SHARED_LIBS)
+  replace_empty_install_prefix()
+
   install(TARGETS kid3-gui
     LIBRARY DESTINATION ${WITH_LIBDIR}
     RUNTIME DESTINATION ${WITH_BINDIR})
+
+  restore_install_prefix()
 endif()
diff --git a/translations/CMakeLists.txt b/translations/CMakeLists.txt
index 898dc0f9..8035dafc 100644
--- a/translations/CMakeLists.txt
+++ b/translations/CMakeLists.txt
@@ -90,5 +90,7 @@ else()
   set(_installQmFiles ${_qmFiles})
 endif()
 if(NOT HAVE_TRANSLATIONSDIR_IN_QRC)
+  replace_empty_install_prefix()
   install(FILES ${_installQmFiles} DESTINATION ${WITH_TRANSLATIONSDIR})
+  restore_install_prefix()
 endif()
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.