[LyX features/biginset] Cmake build wit qt(5|6)(macos) did not include "plugins"

Kornel Benko kornel at lyx.org
Fri Apr 5 13:41:45 UTC 2024


commit 58aca890037e744a3bbe77c68946dcc9984304f1
Author: Patrick de Visschere <pdvisschere at edpnet.be>
Date:   Sat Mar 23 11:25:27 2024 +0100

    Cmake build wit qt(5|6)(macos) did not include "plugins"
    
    This makes things much simpler.
    
    But at least with the latest macos tools (Sonoma and XCode15) a bundle
    refuses to run if it 's not signed properly.
    
    Both issues are solved with the patch included and have now been tested
    with Qt5.15 and Qt6.7.
    
    For completeness: I've checked the font-emph shortcut issue and, as
    reported in the ticket mentioned, ^CmdE works with Qt5.15 but not with
    Qt6.7. However the sequence ^C E does work. I don't know whether this is
    intended as a workaround for this issue or was already implemented.
---
 development/cmake/post_install/CMakeLists.txt | 36 +++++++++++++++++++--------
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/development/cmake/post_install/CMakeLists.txt b/development/cmake/post_install/CMakeLists.txt
index 52a2f782af..f39bb5a763 100644
--- a/development/cmake/post_install/CMakeLists.txt
+++ b/development/cmake/post_install/CMakeLists.txt
@@ -27,15 +27,25 @@ if(LYX_BUNDLE)
         set(qt_conf_path "${LYX_BUNDLE_NAME}.app/Contents/Resources/qt.conf")
     endif()
 
-    if(Qt5Core_FOUND)
-	file(GLOB QT_PLUGIN_DIRECTORIES "${QT_PLUGINS_DIR}/imageformats")
-	install(DIRECTORY ${QT_PLUGIN_DIRECTORIES} DESTINATION "${qtplugin_dest_dir}/plugins/" COMPONENT Runtime REGEX "\\_debug\\.dylib$" EXCLUDE)
-       if(APPLE)
-		if(Qt5Core_VERSION VERSION_GREATER_EQUAL 5.10.0)
-       			install_qt_plugin("Qt5::QMacStylePlugin")
-       		endif()
-        install_qt_plugin("Qt5::QCocoaIntegrationPlugin")
+    if(${LYX_USE_QT} STREQUAL "QT5")
+        set(QtScope "Qt5")
+    elseif(${LYX_USE_QT} STREQUAL "QT6")
+        set(QtScope "Qt6")
+    endif()
+
+    get_target_property( MyLoc "${QtScope}::QSvgPlugin" LOCATION)
+    get_filename_component(MyDir ${MyLoc} PATH)
+    set(QT_PLUGINS_DIR ${MyDir}/..)
+    set(QT_LIBRARY_DIRS ${QT_PLUGINS_DIR}/../lib)
+
+    file(GLOB QT_PLUGIN_DIRECTORIES "${QT_PLUGINS_DIR}/imageformats")
+    install(DIRECTORY ${QT_PLUGIN_DIRECTORIES} DESTINATION "${qtplugin_dest_dir}/plugins/" COMPONENT Runtime REGEX "\\_debug\\.dylib$" EXCLUDE)
+
+    if(APPLE)
+      if(Qt6Core_FOUND OR (Qt5Core_FOUND AND (Qt5Core_VERSION VERSION_GREATER_EQUAL 5.10.0)))
+          install_qt_plugin("${QtScope}::QMacStylePlugin")
        endif()
+       install_qt_plugin("${QtScope}::QCocoaIntegrationPlugin")
     endif()
 
     # Install code does the following:
@@ -47,16 +57,22 @@ if(LYX_BUNDLE)
                     file(GLOB_RECURSE QTPLUGINS
                     \"\${CMAKE_INSTALL_PREFIX}/${qtplugin_dest_dir}/plugins/*/*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
                     message(STATUS \"QT plugins [\${CMAKE_INSTALL_PREFIX}/${qtplugin_dest_dir}/plugins/*/*${CMAKE_SHARED_LIBRARY_SUFFIX}]: \${QTPLUGINS}\")
-                    fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/${installed_lyx_path}\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIRS}\")" 
+                    fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/${installed_lyx_path}\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIRS}\")"
                     COMPONENT Runtime
             )
 
+    if(APPLE)
+        # fixup_bundle invalidates the codesign, so the app must be signed again.
+        add_custom_target(sign_install WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}
+          COMMAND /usr/bin/codesign --deep --force --sign "${CPACK_BUNDLE_APPLE_CERT_APP}" "LyX2.4.app" VERBATIM)
+    endif()
+
     if (APPLE AND LYX_DMG)
         # Setup the disk image layout
         install(CODE "
             message(STATUS \"Creating the folder view options (.DS_Store)\")
             execute_process(COMMAND /bin/ln -sf /Applications \"\${CMAKE_INSTALL_PREFIX}\")
-            execute_process(COMMAND /bin/bash \"${CMAKE_CURRENT_SOURCE_DIR}/../../MacOSX/set_bundle_display_options.sh\" 
+            execute_process(COMMAND /bin/bash \"${CMAKE_CURRENT_SOURCE_DIR}/../../MacOSX/set_bundle_display_options.sh\"
             \"${CMAKE_BINARY_DIR}/ds_store\" \"${_lyx}\" \"${TOP_CMAKE_PATH}/../MacOSX/dmg-background.png\" 560 364)
         ")
     endif()


More information about the lyx-cvs mailing list