[GTK][CMake] Make gtk-unix-print a component of FindGTK.cmake
authoraperez@igalia.com <aperez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Apr 2020 15:26:53 +0000 (15:26 +0000)
committeraperez@igalia.com <aperez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 21 Apr 2020 15:26:53 +0000 (15:26 +0000)
https://bugs.webkit.org/show_bug.cgi?id=210792

Reviewed by Carlos Garcia Campos.

.:

* Source/cmake/FindGTK.cmake: Support an "unix-print" component.
* Source/cmake/FindGTKUnixPrint.cmake: Removed.
* Source/cmake/OptionsGTK.cmake: Use the "unix-print" component of the GTK find module.

Source/WebKit:

No new tests needed.

* PlatformGTK.cmake: Use the GTK::UnixPrint imported target.

Tools:

* TestWebKitAPI/glib/PlatformGTK.cmake: Use the GTK::UnixPrint imported target.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@260427 268f45cc-cd09-0410-ab3c-d52691b4dbfc

ChangeLog
Source/WebKit/ChangeLog
Source/WebKit/PlatformGTK.cmake
Source/cmake/FindGTK.cmake
Source/cmake/FindGTKUnixPrint.cmake [deleted file]
Source/cmake/OptionsGTK.cmake
Tools/ChangeLog
Tools/TestWebKitAPI/glib/PlatformGTK.cmake

index 1b96b83..1c47175 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2020-04-21  Adrian Perez de Castro  <aperez@igalia.com>
+
+        [GTK][CMake] Make gtk-unix-print a component of FindGTK.cmake
+        https://bugs.webkit.org/show_bug.cgi?id=210792
+
+        Reviewed by Carlos Garcia Campos.
+
+        * Source/cmake/FindGTK.cmake: Support an "unix-print" component.
+        * Source/cmake/FindGTKUnixPrint.cmake: Removed.
+        * Source/cmake/OptionsGTK.cmake: Use the "unix-print" component of the GTK find module.
+
 2020-04-20  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK][WPE] Enable resource load statistics
index 37b5781..918d4b2 100644 (file)
@@ -1,3 +1,14 @@
+2020-04-21  Adrian Perez de Castro  <aperez@igalia.com>
+
+        [GTK][CMake] Make gtk-unix-print a component of FindGTK.cmake
+        https://bugs.webkit.org/show_bug.cgi?id=210792
+
+        Reviewed by Carlos Garcia Campos.
+
+        No new tests needed.
+
+        * PlatformGTK.cmake: Use the GTK::UnixPrint imported target.
+
 2020-04-21  Philippe Normand  <pnormand@igalia.com>
 
         [CMake] gst-build-backed build fails
index 1ae8d9b..7948d98 100644 (file)
@@ -426,7 +426,6 @@ list(APPEND WebKit_SYSTEM_INCLUDE_DIRECTORIES
     ${GSTREAMER_INCLUDE_DIRS}
     ${GSTREAMER_PBUTILS_INCLUDE_DIRS}
     ${GTK_INCLUDE_DIRS}
-    ${GTK_UNIX_PRINT_INCLUDE_DIRS}
     ${LIBSOUP_INCLUDE_DIRS}
 )
 
@@ -460,10 +459,6 @@ list(APPEND GPUProcess_SOURCES
     GPUProcess/EntryPoint/unix/GPUProcessMain.cpp
 )
 
-list(APPEND WebKit_LIBRARIES
-    ${GTK_UNIX_PRINT_LIBRARIES}
-)
-
 if (USE_WPE_RENDERER)
     list(APPEND WebKit_LIBRARIES
       WPE::libwpe
@@ -471,6 +466,10 @@ if (USE_WPE_RENDERER)
     )
 endif ()
 
+if (GTK_UNIX_PRINT_FOUND)
+    list(APPEND WebKit_LIBRARIES GTK::UnixPrint)
+endif ()
+
 if (LIBNOTIFY_FOUND)
     list(APPEND WebKit_PRIVATE_LIBRARIES
         ${LIBNOTIFY_LIBRARIES}
index 395b8ea..abb4b86 100644 (file)
@@ -30,11 +30,22 @@ FindGTK
 
 Find GTK headers and libraries.
 
+Optional Components
+^^^^^^^^^^^^^^^^^^^
+
+The ``COMPONENTS`` (or ``OPTIONAL_COMPONENTS``) keyword can be passed to
+``find_package()``, the following GTK components can be searched for:
+
+- ``unix-print``
+
+
 Imported Targets
 ^^^^^^^^^^^^^^^^
 
 ``GTK::GTK``
   The GTK library, if found.
+``GTK::UnixPrint``
+  The GTK unix-print library, if found.
 
 Result Variables
 ^^^^^^^^^^^^^^^^
@@ -43,6 +54,8 @@ This will define the following variables in your project:
 
 ``GTK_FOUND``
   true if (the requested version of) GTK is available.
+``GTK_UNIX_PRINT_FOUND``
+  true if the ``unix-print`` component is available.
 ``GTK_4``
   whether GTK 4 was detected
 ``GTK_3``
@@ -68,10 +81,12 @@ endif ()
 
 if (GTK_FIND_VERSION VERSION_LESS 3.90)
     set(GTK_PC_MODULE "gtk+-3.0")
+    set(GTK_PC_UNIX_PRINT_MODULE "gtk+-unix-print-3.0")
     set(GTK_4 FALSE)
     set(GTK_3 TRUE)
 else ()
     set(GTK_PC_MODULE "gtk4")
+    set(GTK_PC_UNIX_PRINT_MODULE "gtk4-unix-print")
     set(GTK_4 TRUE)
     set(GTK_3 FALSE)
 endif ()
@@ -115,5 +130,21 @@ if (TARGET PkgConfig::GTK AND NOT TARGET GTK::GTK)
     )
 endif ()
 
+# Try to find additional components
+foreach (gtk_component ${GTK_FIND_COMPONENTS})
+    if (NOT "${gtk_component}" STREQUAL unix-print)
+        message(FATAL_ERROR "Invalid component name: ${gtk_component}")
+    endif ()
+    pkg_check_modules(GTK_UNIX_PRINT IMPORTED_TARGET "${GTK_PC_UNIX_PRINT_MODULE}")
+    if (GTK_FIND_REQUIRED_unix-print AND NOT GTK_UNIX_PRINT_FOUND)
+        message(FATAL_ERROR "Component unix-print not found")
+    endif ()
+    if (TARGET PkgConfig::GTK_UNIX_PRINT AND NOT TARGET GTK::UnixPrint)
+        add_library(GTK::UnixPrint INTERFACE IMPORTED GLOBAL)
+        set_property(TARGET GTK::UnixPrint PROPERTY
+            INTERFACE_LINK_LIBRARIES PkgConfig::GTK_UNIX_PRINT)
+    endif ()
+endforeach ()
+
 include(FindPackageHandleStandardArgs)
 FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK DEFAULT_MSG GTK_VERSION GTK_VERSION_OK)
diff --git a/Source/cmake/FindGTKUnixPrint.cmake b/Source/cmake/FindGTKUnixPrint.cmake
deleted file mode 100644 (file)
index 26f0714..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-# - Try to find gtk-unix-print
-# Once done, this will define
-#
-#  GTKUnixPrint_FOUND - system has gtk-unix-print
-#  GTK_UNIX_PRINT_INCLUDE_DIRS - the gtk-unix-print include directories
-#  GTK_UNIX_PRINT_LIBRARIES - link these to use gtk-unix-print
-#
-# Copyright (C) 2012 Raphael Kubo da Costa <rakuco@webkit.org>
-# Copyright (C) 2014 Igalia S.L.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1.  Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-# 2.  Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in the
-#     documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS
-# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS
-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-find_package(PkgConfig QUIET)
-pkg_check_modules(GTK_UNIX_PRINT gtk+-unix-print-3.0)
-
-set(VERSION_OK TRUE)
-if (GTK_UNIX_PRINT_VERSION)
-    if (GTK_UNIX_PRINT_FIND_VERSION_EXACT)
-        if (NOT("${GTK_UNIX_PRINT_FIND_VERSION}" VERSION_EQUAL "${GTK_UNIX_PRINT_VERSION}"))
-            set(VERSION_OK FALSE)
-        endif ()
-    else ()
-        if ("${GTK_UNIX_PRINT_VERSION}" VERSION_LESS "${GTK_UNIX_PRINT_FIND_VERSION}")
-            set(VERSION_OK FALSE)
-        endif ()
-    endif ()
-endif ()
-
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(GTKUnixPrint REQUIRED_VARS GTK_UNIX_PRINT_INCLUDE_DIRS GTK_UNIX_PRINT_LIBRARIES VERSION_OK)
index 6546753..95fc606 100644 (file)
@@ -38,7 +38,7 @@ find_package(Fontconfig 2.8.0 REQUIRED)
 find_package(Freetype 2.4.2 REQUIRED)
 find_package(LibGcrypt 1.6.0 REQUIRED)
 find_package(GLIB 2.44.0 REQUIRED COMPONENTS gio gio-unix gobject gthread gmodule)
-find_package(GTK ${GTK_MINIMUM_VERSION} REQUIRED)
+find_package(GTK ${GTK_MINIMUM_VERSION} REQUIRED OPTIONAL_COMPONENTS unix-print)
 find_package(HarfBuzz 0.9.18 REQUIRED COMPONENTS ICU)
 find_package(ICU 60.2 REQUIRED COMPONENTS data i18n uc)
 find_package(JPEG REQUIRED)
@@ -52,7 +52,6 @@ find_package(ATK 2.16.0 REQUIRED)
 find_package(WebP REQUIRED COMPONENTS demux)
 find_package(ATSPI 2.5.3)
 find_package(EGL)
-find_package(GTKUnixPrint)
 find_package(OpenGL)
 find_package(OpenGLES2)
 
@@ -224,7 +223,7 @@ else ()
 endif ()
 add_definitions(-DSVN_REVISION="${SVN_REVISION}")
 
-SET_AND_EXPOSE_TO_BUILD(HAVE_GTK_UNIX_PRINTING ${GTKUnixPrint_FOUND})
+SET_AND_EXPOSE_TO_BUILD(HAVE_GTK_UNIX_PRINTING ${GTK_UNIX_PRINT_FOUND})
 
 if (USE_WPE_RENDERER)
     find_package(WPE 1.3.0)
index f3cd1ab..6f967e2 100644 (file)
@@ -1,3 +1,12 @@
+2020-04-21  Adrian Perez de Castro  <aperez@igalia.com>
+
+        [GTK][CMake] Make gtk-unix-print a component of FindGTK.cmake
+        https://bugs.webkit.org/show_bug.cgi?id=210792
+
+        Reviewed by Carlos Garcia Campos.
+
+        * TestWebKitAPI/glib/PlatformGTK.cmake: Use the GTK::UnixPrint imported target.
+
 2020-04-21  Philippe Normand  <pnormand@igalia.com>
 
         [Flatpak SDK] Silence git stderr output
index 1471dd6..60dd9df 100644 (file)
@@ -14,15 +14,17 @@ list(APPEND WebKitGLibAPITests_INCLUDE_DIRECTORIES
 
 list(APPEND WebKitGLibAPITests_SYSTEM_INCLUDE_DIRECTORIES
     ${ATSPI_INCLUDE_DIRS}
-    ${GTK_UNIX_PRINT_INCLUDE_DIRS}
 )
 
 list(APPEND WebKitGLibAPITest_LIBRARIES
     ${ATSPI_LIBRARIES}
-    ${GTK_UNIX_PRINT_LIBRARIES}
     GTK::GTK
 )
 
+if (GTK_UNIX_PRINT_FOUND)
+    list(APPEND WebKitGLibAPITest_LIBRARIES GTK::UnixPrint)
+endif ()
+
 list(APPEND WebKitGLibAPIWebProcessTests
     ${TOOLS_DIR}/TestWebKitAPI/Tests/WebKitGtk/AutocleanupsTest.cpp
     ${TOOLS_DIR}/TestWebKitAPI/Tests/WebKitGtk/DOMClientRectTest.cpp