Source: https://github.com/emuse/qmidiarp/pull/19

From 1d5e24bafe29816466af6531990564e26c485537 Mon Sep 17 00:00:00 2001
From: Andreas Sturmlechner <asturm@gentoo.org>
Date: Sun, 14 Dec 2025 22:20:34 +0100
Subject: [PATCH 1/7] CMake: Use GNUInstallDirs properly

- No GNUInstallDirs path concatenation, use CMAKE_INSTALL_FULL_ instead
- Don't hardcode lib
- Drop unused CMake vars
- Deduplicate

Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
---
 CMakeLists.txt                  | 13 ++++++-------
 qmidiarp_arp.lv2/CMakeLists.txt |  3 ---
 qmidiarp_lfo.lv2/CMakeLists.txt |  4 ----
 qmidiarp_seq.lv2/CMakeLists.txt |  3 ---
 src/CMakeLists.txt              | 11 +----------
 5 files changed, 7 insertions(+), 27 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index db0a104..17ccb29 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -21,14 +21,13 @@ else ()
     set(CONFIG_DEBUG 0)
 endif ()
 
-set (CONFIG_PREFIX "${CMAKE_INSTALL_PREFIX}")
-set (CONFIG_LV2DIR "${CMAKE_INSTALL_PREFIX}/lib/lv2")
-
 include (GNUInstallDirs)
-set (CONFIG_BINDIR  "${CONFIG_PREFIX}/${CMAKE_INSTALL_BINDIR}")
-set (CONFIG_LIBDIR  "${CONFIG_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
-set (CONFIG_DATADIR "${CONFIG_PREFIX}/${CMAKE_INSTALL_DATADIR}")
-set (CONFIG_MANDIR  "${CONFIG_PREFIX}/${CMAKE_INSTALL_MANDIR}")
+
+if (CMAKE_INSTALL_PREFIX MATCHES $ENV{HOME})
+  set (CONFIG_LV2DIR "${CMAKE_INSTALL_PREFIX}/.lv2")
+else ()
+  set (CONFIG_LV2DIR "${CMAKE_INSTALL_LIBDIR}/lv2")
+endif ()
 
 option (CONFIG_APPBUILD "Build QMidiArp Application (default=yes)" 1)
 option (CONFIG_FORCE_QT5 "Force Qt5 instead of Qt6 (default=no)" 1)
diff --git a/qmidiarp_arp.lv2/CMakeLists.txt b/qmidiarp_arp.lv2/CMakeLists.txt
index a6d0adc..4fd5840 100644
--- a/qmidiarp_arp.lv2/CMakeLists.txt
+++ b/qmidiarp_arp.lv2/CMakeLists.txt
@@ -1,6 +1,3 @@
-if (CONFIG_PREFIX MATCHES $ENV{HOME})
-set (CONFIG_LV2DIR ${CONFIG_PREFIX}/.lv2)
-endif ()
 install (FILES ${PROJECT_NAME}_arp.ttl DESTINATION ${CONFIG_LV2DIR}/${PROJECT_NAME}_arp.lv2/)
 install (FILES ${PROJECT_NAME}_arp_ui.ttl DESTINATION ${CONFIG_LV2DIR}/${PROJECT_NAME}_arp.lv2/)
 install (FILES manifest.ttl DESTINATION ${CONFIG_LV2DIR}/${PROJECT_NAME}_arp.lv2/)
diff --git a/qmidiarp_lfo.lv2/CMakeLists.txt b/qmidiarp_lfo.lv2/CMakeLists.txt
index 7986133..b3cf98e 100644
--- a/qmidiarp_lfo.lv2/CMakeLists.txt
+++ b/qmidiarp_lfo.lv2/CMakeLists.txt
@@ -1,7 +1,3 @@
-if (CONFIG_PREFIX MATCHES $ENV{HOME})
-set (CONFIG_LV2DIR ${CONFIG_PREFIX}/.lv2)
-endif ()
 install (FILES ${PROJECT_NAME}_lfo.ttl DESTINATION ${CONFIG_LV2DIR}/${PROJECT_NAME}_lfo.lv2/)
 install (FILES ${PROJECT_NAME}_lfo_ui.ttl DESTINATION ${CONFIG_LV2DIR}/${PROJECT_NAME}_lfo.lv2/)
 install (FILES manifest.ttl DESTINATION ${CONFIG_LV2DIR}/${PROJECT_NAME}_lfo.lv2/)
-
diff --git a/qmidiarp_seq.lv2/CMakeLists.txt b/qmidiarp_seq.lv2/CMakeLists.txt
index 6c57f85..124f885 100644
--- a/qmidiarp_seq.lv2/CMakeLists.txt
+++ b/qmidiarp_seq.lv2/CMakeLists.txt
@@ -1,6 +1,3 @@
-if (CONFIG_PREFIX MATCHES $ENV{HOME})
-set (CONFIG_LV2DIR ${CONFIG_PREFIX}/.lv2)
-endif ()
 install (FILES ${PROJECT_NAME}_seq.ttl DESTINATION ${CONFIG_LV2DIR}/${PROJECT_NAME}_seq.lv2/)
 install (FILES ${PROJECT_NAME}_seq_ui.ttl DESTINATION ${CONFIG_LV2DIR}/${PROJECT_NAME}_seq.lv2/)
 install (FILES manifest.ttl DESTINATION ${CONFIG_LV2DIR}/${PROJECT_NAME}_seq.lv2/)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 0990c04..c2d34b9 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -79,7 +79,7 @@ if (APPBUILD)
     
     if (CONFIG_TRANSLATIONS)
         add_subdirectory(translations)
-        set( DTRANSLATIONSDIR -DTRANSLATIONSDIR="${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/${PACKAGE}/translations/" )
+        set( DTRANSLATIONSDIR -DTRANSLATIONSDIR="${CMAKE_INSTALL_FULL_DATADIR}/${PACKAGE}/translations/" )
     endif()
     
     add_executable (${PROJECT_NAME}
@@ -185,9 +185,6 @@ if (BUILD_LV2)
     endif ()
 
     if (UNIX AND NOT APPLE)
-      if (CONFIG_PREFIX MATCHES $ENV{HOME})
-        set (CONFIG_LV2DIR ${CONFIG_PREFIX}/.lv2)
-      endif ()
       install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_arp.so
          DESTINATION ${CONFIG_LV2DIR}/${PROJECT_NAME}_arp.lv2)
       install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_lfo.so
@@ -309,9 +306,6 @@ if (BUILD_LV2_UI)
     endif ()
 
     if (UNIX AND NOT APPLE)
-      if (CONFIG_PREFIX MATCHES $ENV{HOME})
-        set (CONFIG_LV2DIR ${CONFIG_PREFIX}/.lv2)
-      endif ()
       install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_arp_ui.so
          DESTINATION ${CONFIG_LV2DIR}/${PROJECT_NAME}_arp.lv2)
       install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_lfo_ui.so
@@ -386,9 +380,6 @@ if (BUILD_LV2_UI_RTK)
     target_link_libraries (${PROJECT_NAME}_seq_ui_gl PUBLIC -lX11)
 
     if (UNIX AND NOT APPLE)
-      if (CONFIG_PREFIX MATCHES $ENV{HOME})
-        set (CONFIG_LV2DIR ${CONFIG_PREFIX}/.lv2)
-      endif ()
       install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_arp_ui_gl.so
          DESTINATION ${CONFIG_LV2DIR}/${PROJECT_NAME}_arp.lv2)
       install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_lfo_ui_gl.so
-- 
2.52.0


From acb4fd575a559bae7c78b468d8248c25b56806bc Mon Sep 17 00:00:00 2001
From: Andreas Sturmlechner <asturm@gentoo.org>
Date: Sun, 14 Dec 2025 22:27:45 +0100
Subject: [PATCH 2/7] CMake: Fix typo

Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
---
 CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 17ccb29..0e4fde2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -41,7 +41,7 @@ option (CONFIG_LV2_UI_RTK  "Build LV2 plug-in UIs with RobTk (default=yes)" 1)
 
 # Enable NSM support.
 option (CONFIG_NSM "Enable NSM support (default=yes)" 1)
-set (APPBUILD ${CONFIG_APBUILD})
+set (APPBUILD ${CONFIG_APPBUILD})
 
 # Enable translations.
 option (CONFIG_TRANSLATIONS "Build and install translations (default=no)" 1)
-- 
2.52.0


From c105643893e8738491e559e1aa4d3bd68ac571b5 Mon Sep 17 00:00:00 2001
From: Andreas Sturmlechner <asturm@gentoo.org>
Date: Sun, 14 Dec 2025 22:34:44 +0100
Subject: [PATCH 3/7] CMake: Correlate default CMake option value with help
 text next to it

Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
---
 CMakeLists.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0e4fde2..14c450b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -30,7 +30,7 @@ else ()
 endif ()
 
 option (CONFIG_APPBUILD "Build QMidiArp Application (default=yes)" 1)
-option (CONFIG_FORCE_QT5 "Force Qt5 instead of Qt6 (default=no)" 1)
+option (CONFIG_FORCE_QT5 "Force Qt5 instead of Qt6 (default=no)" 0)
 option (CONFIG_JACK_MIDI "Enable JACK MIDI support (default=yes)" 1)
 option (CONFIG_ALSA_MIDI "Enable ALSA MIDI support (default=yes)" 1)
 
@@ -44,7 +44,7 @@ option (CONFIG_NSM "Enable NSM support (default=yes)" 1)
 set (APPBUILD ${CONFIG_APPBUILD})
 
 # Enable translations.
-option (CONFIG_TRANSLATIONS "Build and install translations (default=no)" 1)
+option (CONFIG_TRANSLATIONS "Build and install translations (default=no)" 0)
 set (APPBUILD ${CONFIG_TRANSLATIONS})
 
 # Fix for new CMAKE_REQUIRED_LIBRARIES policy.
-- 
2.52.0


From 6a2a20d187b421aaf360037b99a369c88e6b469a Mon Sep 17 00:00:00 2001
From: Andreas Sturmlechner <asturm@gentoo.org>
Date: Sun, 14 Dec 2025 22:52:20 +0100
Subject: [PATCH 4/7] CMake: Fix translations (at least using Qt6)

Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
---
 CMakeLists.txt                  | 12 +-----------
 src/translations/CMakeLists.txt |  2 +-
 2 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 14c450b..276358e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -71,20 +71,10 @@ if (CONFIG_APPBUILD OR CONFIG_LV2_UI)
   message("Will build GUIs using Qt ${QT_VERSION}")
   # Check for lrelease translations
   if (CONFIG_TRANSLATIONS)
-    find_program (CONFIG_LRELEASE NAMES "lrelease" DOC "lrelease executable location")
-    if (NOT CONFIG_LRELEASE)
-        set(CONFIG_TRANSLATIONS  0)
-        message("Translation generation disabled, lrelease not found")
-    else()
-        find_program (CONFIG_LUPDATE NAMES "lupdate" DOC "lupdate executable location")
-        message("lrelease found: ${CONFIG_LRELEASE}")
-        message("Will build translations")
-    endif()
+    find_package (Qt${QT_VERSION_MAJOR}LinguistTools CONFIG REQUIRED)
   endif()
 endif ()
 
-#find_package (Qt${QT_VERSION_MAJOR}LinguistTools)
-
 include (CheckIncludeFileCXX)
 include (CheckIncludeFiles)
 include (CheckIncludeFile)
diff --git a/src/translations/CMakeLists.txt b/src/translations/CMakeLists.txt
index 8c7f009..4046f91 100644
--- a/src/translations/CMakeLists.txt
+++ b/src/translations/CMakeLists.txt
@@ -14,5 +14,5 @@ set (QM_FILES
 
 # add_custom_target(lupdate ALL COMMAND ${CONFIG_LUPDATE} ${CMAKE_SOURCE_DIR}/src -ts ${TS_SOURCES})
 
-add_custom_target(lrelease ALL COMMAND ${CONFIG_LRELEASE} ${TS_SOURCES})
+add_custom_target(lrelease ALL COMMAND Qt${QT_VERSION_MAJOR}::lrelease ${TS_SOURCES})
 install(FILES ${QM_FILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/${PACKAGE}/translations/)
-- 
2.52.0


From 849be5f867bd470fc4472c6b0ca99dda1ea4eed5 Mon Sep 17 00:00:00 2001
From: Andreas Sturmlechner <asturm@gentoo.org>
Date: Sun, 14 Dec 2025 23:02:40 +0100
Subject: [PATCH 5/7] CMake: Rename CONFIG_DEBUG -> STRIP_DEBUG_SYMBOLS, make
 it a cache entry

New name better describes what this really does.

As a distribution maintainer, I disagree with stripping debug symbols
from the package. But if you must do it, at least give me a way to
override.

Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
---
 CMakeLists.txt     | 5 ++---
 src/CMakeLists.txt | 6 +++---
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 276358e..c9915ec 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,10 +15,9 @@ set (PACKAGE_STRING "${PACKAGE_NAME}-${PACKAGE_VERSION}")
 set (PACKAGE_TARNAME "qmidiarp")
 set (VERSION "${PROJECT_VERSION}")
 
+set(STRIP_DEBUG_SYMBOLS ON CACHE BOOL "Strip debug symbols (default=yes)")
 if (CMAKE_BUILD_TYPE MATCHES "Debug")
-    set(CONFIG_DEBUG 1)
-else ()
-    set(CONFIG_DEBUG 0)
+  set(STRIP_DEBUG_SYMBOLS OFF)
 endif ()
 
 include (GNUInstallDirs)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c2d34b9..7261679 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -103,7 +103,7 @@ if (APPBUILD)
                                                     Qt${QT_VERSION_MAJOR}::Widgets
                                                     )
     
-    if (UNIX AND NOT APPLE AND NOT CONFIG_DEBUG)
+    if (UNIX AND NOT APPLE AND STRIP_DEBUG_SYMBOLS)
       add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
         COMMAND strip ${PROJECT_NAME})
     endif ()
@@ -175,7 +175,7 @@ if (BUILD_LV2)
     set_target_properties (${PROJECT_NAME}_lfo PROPERTIES CXX_STANDARD 11 PREFIX "")
     set_target_properties (${PROJECT_NAME}_seq PROPERTIES CXX_STANDARD 11 PREFIX "")
 
-    if (UNIX AND NOT APPLE AND NOT CONFIG_DEBUG)
+    if (UNIX AND NOT APPLE AND STRIP_DEBUG_SYMBOLS)
       add_custom_command(TARGET ${PROJECT_NAME}_arp  POST_BUILD
         COMMAND strip ${PROJECT_NAME}_arp.so)
       add_custom_command(TARGET ${PROJECT_NAME}_lfo  POST_BUILD
@@ -296,7 +296,7 @@ if (BUILD_LV2_UI)
                                                     Qt${QT_VERSION_MAJOR}::Gui
                                                     Qt${QT_VERSION_MAJOR}::Widgets
                                                     )
-    if (UNIX AND NOT APPLE AND NOT CONFIG_DEBUG)
+    if (UNIX AND NOT APPLE AND STRIP_DEBUG_SYMBOLS)
       add_custom_command(TARGET ${PROJECT_NAME}_arp_ui  POST_BUILD
         COMMAND strip ${PROJECT_NAME}_arp_ui.so)
       add_custom_command(TARGET ${PROJECT_NAME}_lfo_ui  POST_BUILD
-- 
2.52.0


From 745d9228cdfb0154a54435d9411bd2202042ed1b Mon Sep 17 00:00:00 2001
From: Andreas Sturmlechner <asturm@gentoo.org>
Date: Sun, 14 Dec 2025 23:17:44 +0100
Subject: [PATCH 6/7] CMake: Do not install .lv2 files unconditionally, respect
 CONFIG_LV2

Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
---
 CMakeLists.txt | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c9915ec..18c050c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -280,9 +280,11 @@ if (BUILD_LV2 AND CONFIG_LV2_UI_RTK)
 endif ()
 
 add_subdirectory(src)
-add_subdirectory(${PROJECT_NAME}_arp.lv2)
-add_subdirectory(${PROJECT_NAME}_lfo.lv2)
-add_subdirectory(${PROJECT_NAME}_seq.lv2)
+if (BUILD_LV2)
+  add_subdirectory(${PROJECT_NAME}_arp.lv2)
+  add_subdirectory(${PROJECT_NAME}_lfo.lv2)
+  add_subdirectory(${PROJECT_NAME}_seq.lv2)
+endif ()
 add_subdirectory(man)
 add_subdirectory(examples)
 
-- 
2.52.0


From 3ee5c17816d9a420c433a6bc014b90d1702b3774 Mon Sep 17 00:00:00 2001
From: Andreas Sturmlechner <asturm@gentoo.org>
Date: Sun, 14 Dec 2025 23:22:58 +0100
Subject: [PATCH 7/7] CMake: Add new CONFIG_EXAMPLES option

Examples are not commonly enabled by default.

Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
---
 CMakeLists.txt | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 18c050c..c453d31 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -32,6 +32,7 @@ option (CONFIG_APPBUILD "Build QMidiArp Application (default=yes)" 1)
 option (CONFIG_FORCE_QT5 "Force Qt5 instead of Qt6 (default=no)" 0)
 option (CONFIG_JACK_MIDI "Enable JACK MIDI support (default=yes)" 1)
 option (CONFIG_ALSA_MIDI "Enable ALSA MIDI support (default=yes)" 1)
+option (CONFIG_EXAMPLES "Install examples (default=no)" 0)
 
 # Enable LV2 plugin build.
 option (CONFIG_LV2 "Build LV2 plug-ins (default=yes)" 1)
@@ -286,7 +287,9 @@ if (BUILD_LV2)
   add_subdirectory(${PROJECT_NAME}_seq.lv2)
 endif ()
 add_subdirectory(man)
-add_subdirectory(examples)
+if (CONFIG_EXAMPLES)
+  add_subdirectory(examples)
+endif ()
 
 if (EXISTS ${CMAKE_SOURCE_DIR}/configure)
     set(ADD_AUTOCONF_FILES  --add-file=${CMAKE_SOURCE_DIR}/configure
-- 
2.52.0

