diff --git a/CMakeLists.txt b/CMakeLists.txt index 853e794..ba78836 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,4 @@ include(${CMAKE_SOURCE_DIR}/cmake/Version.cmake) -include(${CMAKE_SOURCE_DIR}/cmake/Constants.cmake) cmake_minimum_required(VERSION 3.5) project(snapshot LANGUAGES CXX) diff --git a/README.md b/README.md index b9aefbe..9a7430e 100644 --- a/README.md +++ b/README.md @@ -645,6 +645,7 @@ more information. # TODO: +- [ ] currently, all plugins are installed, the regexes are not working. - [ ] Configure `cmake --install` for both static and shared qt builds. This is needed after building the project from source. - [ ] Ensure that the tarball can also be made using the --shared option. diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 51e6962..a665f78 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -5,11 +5,7 @@ add_executable(snapshot_bin main.cpp target_link_libraries(snapshot_bin PRIVATE snapshot) install(PROGRAMS ${CMAKE_SOURCE_DIR}/scripts/run_snapshot DESTINATION .) -install( - TARGETS snapshot_bin - DESTINATION . - RUNTIME_DEPENDENCIES DIRECTORIES ${FFMPEG_LIBRARY_DIRS} POST_EXCLUDE_REGEXES - ${EXCLUDE_C_LIBS_REGEX}) +install_with_runtime_dependencies(snapshot_bin) if(QT6_LIB_TYPE STREQUAL "SHARED_LIBRARY") install_qt_shared_plugins() diff --git a/cmake/Build.cmake b/cmake/Build.cmake index f32d52b..389511e 100644 --- a/cmake/Build.cmake +++ b/cmake/Build.cmake @@ -1,22 +1,5 @@ include(${CMAKE_SOURCE_DIR}/cmake/Find.cmake) -# cmake-format: off -# When building the project with a static Qt6 library, we need to link the -# Libva library to the Qt6 FFmpeg media plugin. This is necessary because -# otherwise some symbols are not found when linking the snapshot. -# cmake-format: on -macro(link_libva_to_ffmpeg_plugin) - find_libva() # creates Libva::va/va-drm/va-x11/va-wayland - get_target_property(QT6_QFFMPEGMEDIAPLUGIN_INTERFACE_LINK_LIBRARIES - Qt6::QFFmpegMediaPlugin INTERFACE_LINK_LIBRARIES) - list(APPEND QT6_QFFMPEGMEDIAPLUGIN_INTERFACE_LINK_LIBRARIES Libva::va - Libva::va-drm Libva::va-x11 Libva::va-wayland) - set_target_properties( - Qt6::QFFmpegMediaPlugin - PROPERTIES INTERFACE_LINK_LIBRARIES - "${QT6_QFFMPEGMEDIAPLUGIN_INTERFACE_LINK_LIBRARIES}") -endmacro() - # cmake-format: off # When building the project with a static Qt6 library, we need to link the # following components statically as well: @@ -31,20 +14,19 @@ macro(target_link_libraries_static_qt) set(PLATFORM_PLUGINS Qt6::QEglFSIntegrationPlugin Qt6::QLinuxFbIntegrationPlugin - Qt6::QMinimalEglIntegrationPlugin - Qt6::QMinimalIntegrationPlugin Qt6::QOffscreenIntegrationPlugin Qt6::QVkKhrDisplayIntegrationPlugin - Qt6::QVncIntegrationPlugin Qt6::QWaylandEglPlatformIntegrationPlugin Qt6::QWaylandIntegrationPlugin Qt6::QXcbIntegrationPlugin) + set(MULTIMEDIA_PLUGINS Qt6::QFFmpegMediaPlugin) + link_libva_to_ffmpeg_plugin() # Plugins are not linked automatically when building with a static Qt6 # library, so we need to link them manually. - list(APPEND LINK_LIBS FFmpeg::FFmpeg Qt6::QFFmpegMediaPlugin + list(APPEND LINK_LIBS FFmpeg::FFmpeg ${MULTIMEDIA_PLUGINS} ${PLATFORM_PLUGINS}) target_link_libraries(snapshot PUBLIC ${LINK_LIBS}) @@ -56,8 +38,25 @@ macro(target_link_libraries_static_qt) ${PLATFORM_PLUGINS} INCLUDE_BY_TYPE multimedia - Qt6::QFFmpegMediaPlugin + ${MULTIMEDIA_PLUGINS} EXCLUDE Qt6::QGstreamerMediaPlugin NO_DEFAULT) endmacro() + +# cmake-format: off +# When building the project with a static Qt6 library, we need to link the +# Libva library to the Qt6 FFmpeg media plugin. This is necessary because +# otherwise some symbols are not found when linking the snapshot. +# cmake-format: on +macro(link_libva_to_ffmpeg_plugin) + find_libva() # creates Libva::va/va-drm/va-x11/va-wayland + get_target_property(QT6_QFFMPEGMEDIAPLUGIN_INTERFACE_LINK_LIBRARIES + ${MULTIMEDIA_PLUGINS} INTERFACE_LINK_LIBRARIES) + list(APPEND QT6_QFFMPEGMEDIAPLUGIN_INTERFACE_LINK_LIBRARIES Libva::va + Libva::va-drm Libva::va-x11 Libva::va-wayland) + set_target_properties( + ${MULTIMEDIA_PLUGINS} + PROPERTIES INTERFACE_LINK_LIBRARIES + "${QT6_QFFMPEGMEDIAPLUGIN_INTERFACE_LINK_LIBRARIES}") +endmacro() diff --git a/cmake/Constants.cmake b/cmake/Constants.cmake deleted file mode 100644 index 3430a89..0000000 --- a/cmake/Constants.cmake +++ /dev/null @@ -1,7 +0,0 @@ -# Compatability with the following C libraries across linux distributions is -# assumed. Use this constant in the install command to exclude these libraries -# from the installation. -set(EXCLUDE_C_LIBS_REGEX - ".*ld-linux.*\\.so.*" ".*libc\\.so.*" ".*libm\\.so.*" ".*libdbm\\.so.*" - ".*libpthread\\.so.*" - CACHE STRING "Regular expression to exclude C libraries from installation") diff --git a/cmake/Install.cmake b/cmake/Install.cmake index aaac73c..3e88f92 100644 --- a/cmake/Install.cmake +++ b/cmake/Install.cmake @@ -1,61 +1,63 @@ +function(install_with_runtime_dependencies binary) + # Compatability with the following C libraries across linux distributions is + # assumed. Use this constant in the install command to exclude these libraries + # from the installation. + set(exclude_c_libs_regex + ".*ld-linux.*\\.so.*" ".*libc\\.so.*" ".*libm\\.so.*" ".*libdbm\\.so.*" + ".*libpthread\\.so.*") + + install( + TARGETS ${binary} + DESTINATION . + RUNTIME_DEPENDENCIES DIRECTORIES ${FFMPEG_LIBRARY_DIRS} + POST_EXCLUDE_REGEXES ${exclude_c_libs_regex}) +endfunction() + # When Qt is built as a shared library, the platform plugins must be installed # alongside the application in the directories that have the same name as in the # qt source. macro(install_qt_shared_plugins) - # Natually, we need X11 and Wayland support. Eglfs and Linuxfb are also needed # as a Raspberry Pi may require them. Offscreen is usefull when you do not # have a display available. Lets also support vulkan. install( - DIRECTORY ${QT6_TOP_DIR}/plugins/platforms/ - DESTINATION platforms - PATTERN "libqeglfs-.*" - PATTERN "libqlinuxfb.*" - PATTERN "libqoffscreen.*" - PATTERN "libqvkkhrdisplay.*" - PATTERN "libqwayland-.*" - PATTERN "libqxcb.*") + FILES ${QT6_TOP_DIR}/plugins/platforms/libqeglfs.so + ${QT6_TOP_DIR}/plugins/platforms/libqlinuxfb.so + ${QT6_TOP_DIR}/plugins/platforms/libqoffscreen.so + ${QT6_TOP_DIR}/plugins/platforms/libqvkkhrdisplay.so + ${QT6_TOP_DIR}/plugins/platforms/libqwayland-egl.so + ${QT6_TOP_DIR}/plugins/platforms/libqwayland-generic.so + ${QT6_TOP_DIR}/plugins/platforms/libqxcb.so + DESTINATION platforms) # Support both egl and glx. - install( - DIRECTORY ${QT6_TOP_DIR}/plugins/xcbglintegrations/ - DESTINATION xcbglintegrations - PATTERN "libqxcb-.*-integration\\.*") + install(DIRECTORY ${QT6_TOP_DIR}/plugins/xcbglintegrations/ + DESTINATION xcbglintegrations) - # Support all the wayland graphics integrations. + # Support all the wayland graphics integrations, except emulation. install( - DIRECTORY ${QT6_TOP_DIR}/plugins/wayland-graphics-integration-client/ - DESTINATION wayland-graphics-integration-client - PATTERN "libdmabuf-server\\..*" - PATTERN "libdrm-egl-server\\..*" - PATTERN "libqt-plugin-wayland-egl\\..*" - PATTERN "libshm-emulation-server\\..*" - PATTERN "libvulkan-server\\..*") + FILES + ${QT6_TOP_DIR}/plugins/wayland-graphics-integration-client/libdmabuf-server.so + ${QT6_TOP_DIR}/plugins/wayland-graphics-integration-client/libdrm-egl-server.so + ${QT6_TOP_DIR}/plugins/wayland-graphics-integration-client/libqt-plugin-wayland-egl.so + ${QT6_TOP_DIR}/plugins/wayland-graphics-integration-client/libvulkan-server.so + DESTINATION wayland-graphics-integration-client) # X11 support for eglfs can be used by Raspberry Pi. install( - DIRECTORY ${QT6_TOP_DIR}/plugins/egldeviceintegrations/ - DESTINATION egldeviceintegrations - PATTERN "libqeglfs-x11-.*") + FILES + ${QT6_TOP_DIR}/plugins/egldeviceintegrations/libqeglfs-x11-integration.so + DESTINATION egldeviceintegrations) # Support all shells - install( - DIRECTORY ${QT6_TOP_DIR}/plugins/wayland-shell-integration/ - DESTINATION wayland-shell-integration - PATTERN ".*-shell\\..*" - PATTERN ".*-shell-v1\\..*" - PATTERN ".*-shell-plugin\\..*") + install(DIRECTORY ${QT6_TOP_DIR}/plugins/wayland-shell-integration/ + DESTINATION wayland-shell-integration) - # Only saving as jpeg is supported. - install( - DIRECTORY ${QT6_TOP_DIR}/plugins/imageformats/ - DESTINATION imageformats - PATTERN "libqjpeg\\..*") + # Jpeg is needded for image support. + install(FILES ${QT6_TOP_DIR}/plugins/imageformats/libqjpeg.so + DESTINATION imageformats) # Only ffmpeg is supported. - install( - DIRECTORY ${QT6_TOP_DIR}/plugins/multimedia/ - DESTINATION multimedia - PATTERN "libffmpegmediaplugin\\..*") - + install(FILES ${QT6_TOP_DIR}/plugins/multimedia/libffmpegmediaplugin.so + DESTINATION multimedia) endmacro() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 90fb8e2..ba92b15 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,3 +1,5 @@ +include(${CMAKE_SOURCE_DIR}/cmake/Install.cmake) + find_package(Qt6 REQUIRED COMPONENTS Test) include(GoogleTest) include(FetchContent) @@ -18,8 +20,4 @@ set_tests_properties(tests_bin PROPERTIES ENVIRONMENT install(PROGRAMS ${CMAKE_SOURCE_DIR}/scripts/run_tests DESTINATION .) install(DIRECTORY static DESTINATION .) -install( - TARGETS tests_bin - DESTINATION . - RUNTIME_DEPENDENCIES DIRECTORIES ${FFMPEG_LIBRARY_DIRS} POST_EXCLUDE_REGEXES - ${EXCLUDE_C_LIBS_REGEX}) +install_with_runtime_dependencies(tests_bin)