Skip to content

Commit

Permalink
CMake: Improve Dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
HTRamsey committed Oct 19, 2024
1 parent 68afef9 commit 68228a9
Show file tree
Hide file tree
Showing 17 changed files with 546 additions and 46 deletions.
16 changes: 9 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,28 +150,23 @@ if(ANDROID)
message(STATUS "QT_ANDROID_KEYSTORE_ALIAS $ENV{QT_ANDROID_KEYSTORE_ALIAS}")
# QT_ANDROID_KEYSTORE_STORE_PASS, QT_ANDROID_KEYSTORE_KEY_PASS
endif()

if(NOT Qt6LinguistTools_DIR)
set(Qt6LinguistTools_DIR ${QT_HOST_PATH}/lib/cmake/Qt6LinguistTools)
endif()
endif()

find_package(Qt6
REQUIRED
COMPONENTS
Bluetooth
Charts
Concurrent
Core
Core5Compat
Location
Multimedia
Network
Positioning
Qml
QmlIntegration
Quick
QuickControls2
QuickWidgets
OpenGL
Sensors
Sql
Svg
Expand All @@ -180,15 +175,22 @@ find_package(Qt6
Widgets
Xml
OPTIONAL_COMPONENTS
Bluetooth
Charts
LinguistTools
MultimediaQuickPrivate
OpenGL
Quick3D
SerialPort
WaylandClient
HINTS
${QT_LIBRARY_HINTS}
)

if(NOT Qt6LinguistTools_DIR)
set(Qt6LinguistTools_DIR ${QT_HOST_PATH}/lib/cmake/Qt6LinguistTools)
endif()

# Require 6.6.3 because otherwise libQt6QuickControls2Basic.so.6 &
# libQt6QuickControls2BasicStyleImpl.so.6 are missing.
qt_standard_project_setup(REQUIRES 6.6.3)
Expand Down
12 changes: 12 additions & 0 deletions cmake/find-modules/FindBlueZ.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause

set(BlueZ_FOUND 0)

find_package(PkgConfig QUIET)

pkg_check_modules(BLUEZ bluez IMPORTED_TARGET)

if(TARGET PkgConfig::BLUEZ)
set(BlueZ_FOUND 1)
endif()
97 changes: 97 additions & 0 deletions cmake/find-modules/FindFlite.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause

# We can't create the same interface imported target multiple times, CMake will complain if we do
# that. This can happen if the find_package call is done in multiple different subdirectories.
if(TARGET Flite::Flite)
set(Flite_FOUND 1)
return()
endif()

find_path(Flite_INCLUDE_DIR
NAMES
flite/flite.h
)
find_library(Flite_LIBRARY
NAMES
flite
)

if(NOT Flite_INCLUDE_DIR OR NOT Flite_LIBRARY)
set(Flite_FOUND 0)
return()
endif()

include(CMakePushCheckState)
include(CheckCXXSourceCompiles)

# Flite can be built with ALSA support,
# in which case we need to link ALSA as well
find_package(ALSA QUIET)

cmake_push_check_state(RESET)

set(CMAKE_REQUIRED_INCLUDES "${Flite_INCLUDE_DIR}")
set(CMAKE_REQUIRED_LIBRARIES "${Flite_LIBRARY}")

if(ALSA_FOUND)
list(APPEND CMAKE_REQUIRED_LIBRARIES "${ALSA_LIBRARIES}")
endif()

check_cxx_source_compiles("
#include <flite/flite.h>
static int fliteAudioCb(const cst_wave *w, int start, int size,
int last, cst_audio_streaming_info *asi)
{
(void)w;
(void)start;
(void)size;
(void)last;
(void)asi;
return CST_AUDIO_STREAM_STOP;
}
int main()
{
cst_audio_streaming_info *asi = new_audio_streaming_info();
asi->asc = fliteAudioCb; // This fails for old Flite
new_audio_streaming_info();
return 0;
}
" HAVE_FLITE)

cmake_pop_check_state()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Flite
FOUND_VAR
Flite_FOUND
REQUIRED_VARS
Flite_LIBRARY
Flite_INCLUDE_DIR
HAVE_FLITE
)

if(Flite_FOUND)
add_library(Flite::Flite UNKNOWN IMPORTED)
set_target_properties(Flite::Flite PROPERTIES
IMPORTED_LOCATION "${Flite_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${Flite_INCLUDE_DIR}"
)
if(ALSA_FOUND)
set_target_properties(Flite::Flite PROPERTIES
INTERFACE_LINK_LIBRARIES "${ALSA_LIBRARIES}"
)
endif()
endif()

mark_as_advanced(Flite_LIBRARY Flite_INCLUDE_DIR HAVE_FLITE)


if(HAVE_FLITE)
set(Flite_FOUND 1)
else()
message("Flite was found, but the version is too old (<2.0.0)")
set(Flite_FOUND 0)
endif()
64 changes: 57 additions & 7 deletions cmake/find-modules/FindGStreamer.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -296,16 +296,65 @@ find_gstreamer_component(Gl
################################################################################

set(GST_DEPENDENCIES)
list(APPEND GST_DEPENDENCIES GLIB2::GLIB2 GLIB2::GOBJECT GLIB2::GIO GObject::GObject)
find_package(GLESv2 QUIET)
list(APPEND GST_DEPENDENCIES GLESv2::GLESv2)
find_package(OpenGL QUIET OPTIONAL_COMPONENTS EGL GLX OpenGL) # GLES2 GLES3
list(APPEND GST_DEPENDENCIES OpenGL::GL OpenGL::EGL OpenGL::GLX OpenGL::OpenGL)
find_package(X11 QUIET)
list(APPEND GST_DEPENDENCIES X11::X11)
find_package(XRender QUIET)
list(APPEND GST_DEPENDENCIES Pkgconfig::XRender)
find_package(XCB QUIET)
list(APPEND GST_DEPENDENCIES XCB::XCB)
find_package(X11_XCB QUIET)
list(APPEND GST_DEPENDENCIES X11::XCB)
find_package(XKB QUIET)
list(APPEND GST_DEPENDENCIES XKB::XKB)
find_package(XKB_COMMON_X11 QUIET)
list(APPEND GST_DEPENDENCIES PkgConfig::XKB_COMMON_X11)
find_package(EGL QUIET)
list(APPEND GST_DEPENDENCIES EGL::EGL)
pkg_check_modules(PC_libdrm IMPORTED_TARGET libdrm)
list(APPEND GST_DEPENDENCIES PkgConfig::PC_libdrm)
find_package(Wayland QUIET)
list(APPEND GST_DEPENDENCIES Wayland::Client Wayland::Cursor Wayland::Egl)
find_package(Libdrm QUIET)
list(APPEND GST_DEPENDENCIES Libdrm::Libdrm)
find_package(gbm QUIET)
list(APPEND GST_DEPENDENCIES gbm::gbm)
find_package(FFmpeg QUIET)
list(APPEND GST_DEPENDENCIES FFmpeg::FFmpeg)
find_package(Fontconfig QUIET)
list(APPEND GST_DEPENDENCIES Fontconfig::Fontconfig)
find_package(Freetype QUIET)
list(APPEND GST_DEPENDENCIES Freetype::Freetype)
find_package(Iconv QUIET)
list(APPEND GST_DEPENDENCIES Iconv::Iconv)
find_package(Intl QUIET)
list(APPEND GST_DEPENDENCIES Intl::Intl)
find_package(JPEG QUIET)
list(APPEND GST_DEPENDENCIES JPEG::JPEG)
find_package(PNG QUIET)
list(APPEND GST_DEPENDENCIES PNG::PNG)
find_package(BZip2 QUIET)
list(APPEND GST_DEPENDENCIES BZip2::BZip2)
find_package(EXPAT QUIET)
list(APPEND GST_DEPENDENCIES EXPAT::EXPAT)
find_package(LibXml2 QUIET)
list(APPEND GST_DEPENDENCIES LibXml2::LibXml2)
find_package(LibLZMA QUIET)
list(APPEND GST_DEPENDENCIES LibLZMA::LibLZMA)
find_package(TIFF QUIET)
list(APPEND GST_DEPENDENCIES TIFF::TIFF)
find_package(ZLIB QUIET)
list(APPEND GST_DEPENDENCIES ZLIB::ZLIB)
find_package(VAAPI QUIET)
list(APPEND GST_DEPENDENCIES VAAPI::VAAPI)
find_package(Vulkan QUIET)
list(APPEND GST_DEPENDENCIES Vulkan::Vulkan)
find_package(OpenCL)
list(APPEND GST_DEPENDENCIES OpenCL::OpenCL)
find_package(Threads)
list(APPEND GST_DEPENDENCIES Threads::Threads)
pkg_check_modules(PC_gudev IMPORTED_TARGET gudev-1.0)
list(APPEND GST_DEPENDENCIES PkgConfig::PC_gudev)
cmake_print_variables(GST_DEPENDENCIES)
Expand Down Expand Up @@ -641,6 +690,8 @@ set(GST_PLUGINS
gstx264
gstasf
gstva
gstapp
gstvaapi
# gstqml6
)
if(ANDROID)
Expand All @@ -651,7 +702,7 @@ endif()

foreach(plugin IN LISTS GST_PLUGINS)
if(PkgConfig_FOUND)
pkg_check_modules(GST_PLUGIN_${plugin} IMPORTED_TARGET ${plugin})
pkg_check_modules(GST_PLUGIN_${plugin} QUIET IMPORTED_TARGET ${plugin})
if(GST_PLUGIN_${plugin}_FOUND)
target_link_libraries(GStreamer::Plugins INTERFACE PkgConfig::GST_PLUGIN_${plugin})
endif()
Expand All @@ -665,15 +716,14 @@ foreach(plugin IN LISTS GST_PLUGINS)
${GSTREAMER_PLUGIN_PATH}
)
if(GST_PLUGIN_${plugin}_LIBRARY)
cmake_print_variables(plugin)
target_link_libraries(GStreamer::Plugins INTERFACE ${GST_PLUGIN_${plugin}_LIBRARY})
set(GST_PLUGIN_${plugin}_FOUND TRUE)
endif()
endif()

# if(GST_PLUGIN_${plugin}_FOUND)
# cmake_print_variables(plugin)
# endif()
if(GST_PLUGIN_${plugin}_FOUND)
cmake_print_variables(plugin)
endif()
endforeach()

if(NOT MACOS)
Expand Down
15 changes: 15 additions & 0 deletions cmake/find-modules/FindGTK3.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause

find_package(PkgConfig QUIET)

set(__gtk3_required_version "${${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION}")
if(__gtk3_required_version)
set(__gtk3_required_version " >= ${__gtk3_required_version}")
endif()
pkg_check_modules(GTK3 IMPORTED_TARGET "gtk+-3.0${__gtk3_required_version}")

if (NOT TARGET PkgConfig::GTK3)
set(GTK3_FOUND 0)
endif()
unset(__gtk3_required_version)
File renamed without changes.
Loading

0 comments on commit 68228a9

Please sign in to comment.