]> git.lyx.org Git - lyx.git/blob - development/cmake/post_install/CMakeLists.txt
Update sk.po
[lyx.git] / development / cmake / post_install / CMakeLists.txt
1 # Finish the construction of the bundle
2 # by including the necessary QT libraries
3
4 set(QTPLUGINS "")
5
6 # Find a qt plugin and install it in the plugins directory
7 macro(install_qt_plugin _qt_plugin_name)
8     get_target_property(qtlib "${_qt_plugin_name}" LOCATION)
9     if(EXISTS ${qtlib})
10         get_filename_component(qtdir ${qtlib} PATH)
11         get_filename_component(qtdir ${qtdir} NAME)
12         # Installing QT plugin ${qtlib} into ${qtplugin_dest_dir}/plugins/${qtdir}
13         install(FILES "${qtlib}" DESTINATION ${qtplugin_dest_dir}/plugins/${qtdir} COMPONENT Runtime)
14     else()
15         message(FATAL_ERROR "Could not find QT plugin ${_qt_plugin_name}")
16     endif()
17 endmacro()
18
19 if(LYX_BUNDLE)
20     if(NOT APPLE)
21         set(installed_lyx_path bin/${_lyx}${CMAKE_EXECUTABLE_SUFFIX})
22         set(qtplugin_dest_dir bin)
23         set(qt_conf_path bin/qt.conf)
24     else()
25         set(installed_lyx_path ${LYX_BUNDLE_NAME}.app)
26         set(qtplugin_dest_dir "${LYX_BUNDLE_NAME}.app/Contents")
27         set(qt_conf_path "${LYX_BUNDLE_NAME}.app/Contents/Resources/qt.conf")
28     endif()
29
30     if(${LYX_USE_QT} STREQUAL "QT5")
31         set(QtScope "Qt5")
32     elseif(${LYX_USE_QT} STREQUAL "QT6")
33         set(QtScope "Qt6")
34     endif()
35
36     get_target_property( MyLoc "${QtScope}::QSvgPlugin" LOCATION)
37     get_filename_component(MyDir ${MyLoc} PATH)
38     set(QT_PLUGINS_DIR ${MyDir}/..)
39     set(QT_LIBRARY_DIRS ${QT_PLUGINS_DIR}/../lib)
40
41     file(GLOB QT_PLUGIN_DIRECTORIES "${QT_PLUGINS_DIR}/imageformats")
42     install(DIRECTORY ${QT_PLUGIN_DIRECTORIES} DESTINATION "${qtplugin_dest_dir}/plugins/" COMPONENT Runtime REGEX "\\_debug\\.dylib$" EXCLUDE)
43
44     if(APPLE)
45       if(Qt6Core_FOUND OR (Qt5Core_FOUND AND (Qt5Core_VERSION VERSION_GREATER_EQUAL 5.10.0)))
46           install_qt_plugin("${QtScope}::QMacStylePlugin")
47        endif()
48        install_qt_plugin("${QtScope}::QCocoaIntegrationPlugin")
49     endif()
50
51     if (APPLE AND LYX_USE_QT MATCHES "QT6")
52       # With QT6, just copy all the plugins
53       file(GLOB QT_PLUGIN_DIRECTORIES "${QT_PLUGINS_DIR}/*")
54       install(DIRECTORY ${QT_PLUGIN_DIRECTORIES} DESTINATION "${qtplugin_dest_dir}/plugins/" COMPONENT Runtime)
55     endif()
56     # Install code does the following:
57     # - Creates the qt.conf file
58     # - install the platform specific plugins (with Qt5)
59     # - Fixup the bundle
60     install(CODE "include(BundleUtilities)
61                     file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qt_conf_path}\" \"[Paths]\\rPlugins = PlugIns\\rTranslations = translations\")
62                     file(GLOB_RECURSE QTPLUGINS
63                     \"\${CMAKE_INSTALL_PREFIX}/${qtplugin_dest_dir}/plugins/*/*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
64                     message(STATUS \"QT plugins [\${CMAKE_INSTALL_PREFIX}/${qtplugin_dest_dir}/plugins/*/*${CMAKE_SHARED_LIBRARY_SUFFIX}]: \${QTPLUGINS}\")
65                     fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/${installed_lyx_path}\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIRS}\")"
66                     COMPONENT Runtime
67             )
68
69     if(APPLE)
70         # fixup_bundle invalidates the codesign, so the app must be signed again.
71         add_custom_target(sign_install WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}
72           COMMAND /usr/bin/codesign --deep --force --sign "${CPACK_BUNDLE_APPLE_CERT_APP}" "LyX2.4.app" VERBATIM)
73     endif()
74
75     if (APPLE AND LYX_DMG)
76         # Setup the disk image layout
77         install(CODE "
78             message(STATUS \"Creating the folder view options (.DS_Store)\")
79             execute_process(COMMAND /bin/ln -sf /Applications \"\${CMAKE_INSTALL_PREFIX}\")
80             execute_process(COMMAND /bin/bash \"${CMAKE_CURRENT_SOURCE_DIR}/../../MacOSX/set_bundle_display_options.sh\"
81             \"${CMAKE_BINARY_DIR}/ds_store\" \"${_lyx}\" \"${TOP_CMAKE_PATH}/../MacOSX/dmg-background.png\" 560 364)
82         ")
83     endif()
84 endif()