[CMake] Use builtin targets
authordon.olmstead@sony.com <don.olmstead@sony.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Feb 2020 15:37:39 +0000 (15:37 +0000)
committerdon.olmstead@sony.com <don.olmstead@sony.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Feb 2020 15:37:39 +0000 (15:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=205166

Reviewed by Darin Adler.

.:

Add WebKitFindPackage.cmake which wraps CMake's find_package to provide targets
for common libraries.

Rationale:
1. There are a number of libraries which are found using CMake's internal Find modules
   that contain targets but not all of them are available in the minimum version of
   CMake we support, 3.10.
2. Updating to CMake 3.12 or higher is not possible due to the WebKit GTK's support
   policy. It looks like the next time we can bump the version is spring 2021.
3. Apple builds, both Mac and Windows, have libraries that won't be found using the
   stock CMake modules. AppleWin also has internal builds where all libraries have
   a DEBUG_SUFFIX of _debug that would not be picked up.

In the implementation of find_package any Apple specific requirements are dealt with
and the expected CMake values are populated. For all other cases CMake's original
find_package is called so there's no behavior change. Afterwards if there is a library
that has a target but the target was not created it is created from the definitions
that are present from the find module at CMake 3.10.

This makes it so all ports consistently have targets across all versions of CMake
above the current minimum.

* Source/cmake/OptionsAppleWin.cmake:
* Source/cmake/OptionsPlayStation.cmake:
* Source/cmake/WebKitCommon.cmake:
* Source/cmake/WebKitFindPackage.cmake: Added.
* Source/cmake/target/icu.cmake: Removed.

PerformanceTests:

* MallocBench/MallocBench/CMakeLists.txt:

Source/WebCore:

* CMakeLists.txt:
* PlatformGTK.cmake:
* PlatformMac.cmake:
* platform/Curl.cmake:
* platform/FreeType.cmake:
* platform/ImageDecoders.cmake:

Source/WebCore/PAL:

* pal/PlatformPlayStation.cmake:

Source/WebKit:

* PlatformFTW.cmake:
* PlatformWPE.cmake:
* PlatformWin.cmake:

Source/WebKitLegacy:

* PlatformFTW.cmake:
* PlatformWin.cmake:

Source/WTF:

* wtf/PlatformGTK.cmake:
* wtf/PlatformJSCOnly.cmake:
* wtf/PlatformPlayStation.cmake:
* wtf/PlatformWPE.cmake:

Tools:

* TestWebKitAPI/PlatformWin.cmake:

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

31 files changed:
ChangeLog
PerformanceTests/ChangeLog
PerformanceTests/MallocBench/MallocBench/CMakeLists.txt
Source/WTF/ChangeLog
Source/WTF/wtf/PlatformGTK.cmake
Source/WTF/wtf/PlatformJSCOnly.cmake
Source/WTF/wtf/PlatformPlayStation.cmake
Source/WTF/wtf/PlatformWPE.cmake
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/pal/PlatformPlayStation.cmake
Source/WebCore/PlatformGTK.cmake
Source/WebCore/PlatformMac.cmake
Source/WebCore/platform/Curl.cmake
Source/WebCore/platform/FreeType.cmake
Source/WebCore/platform/ImageDecoders.cmake
Source/WebKit/ChangeLog
Source/WebKit/PlatformFTW.cmake
Source/WebKit/PlatformWPE.cmake
Source/WebKit/PlatformWin.cmake
Source/WebKitLegacy/ChangeLog
Source/WebKitLegacy/PlatformFTW.cmake
Source/WebKitLegacy/PlatformWin.cmake
Source/cmake/OptionsAppleWin.cmake
Source/cmake/OptionsPlayStation.cmake
Source/cmake/WebKitCommon.cmake
Source/cmake/WebKitFindPackage.cmake [new file with mode: 0644]
Source/cmake/target/icu.cmake [deleted file]
Tools/ChangeLog
Tools/TestWebKitAPI/PlatformWin.cmake

index 8df0984..1acd51d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,38 @@
+2020-02-17  Don Olmstead  <don.olmstead@sony.com>
+
+        [CMake] Use builtin targets
+        https://bugs.webkit.org/show_bug.cgi?id=205166
+
+        Reviewed by Darin Adler.
+
+        Add WebKitFindPackage.cmake which wraps CMake's find_package to provide targets
+        for common libraries.
+
+        Rationale:
+        1. There are a number of libraries which are found using CMake's internal Find modules
+           that contain targets but not all of them are available in the minimum version of
+           CMake we support, 3.10.
+        2. Updating to CMake 3.12 or higher is not possible due to the WebKit GTK's support
+           policy. It looks like the next time we can bump the version is spring 2021.
+        3. Apple builds, both Mac and Windows, have libraries that won't be found using the
+           stock CMake modules. AppleWin also has internal builds where all libraries have
+           a DEBUG_SUFFIX of _debug that would not be picked up.
+
+        In the implementation of find_package any Apple specific requirements are dealt with
+        and the expected CMake values are populated. For all other cases CMake's original
+        find_package is called so there's no behavior change. Afterwards if there is a library
+        that has a target but the target was not created it is created from the definitions
+        that are present from the find module at CMake 3.10.
+
+        This makes it so all ports consistently have targets across all versions of CMake
+        above the current minimum.
+
+        * Source/cmake/OptionsAppleWin.cmake:
+        * Source/cmake/OptionsPlayStation.cmake:
+        * Source/cmake/WebKitCommon.cmake:
+        * Source/cmake/WebKitFindPackage.cmake: Added.
+        * Source/cmake/target/icu.cmake: Removed.
+
 2020-02-14  Don Olmstead  <don.olmstead@sony.com>
 
         [CMake] Add Fontconfig::Fontconfig target
index 97cda05..0f09307 100644 (file)
@@ -1,3 +1,12 @@
+2020-02-17  Don Olmstead  <don.olmstead@sony.com>
+
+        [CMake] Use builtin targets
+        https://bugs.webkit.org/show_bug.cgi?id=205166
+
+        Reviewed by Darin Adler.
+
+        * MallocBench/MallocBench/CMakeLists.txt:
+
 2020-01-28  Sihui Liu  <sihui_liu@apple.com>
 
         IndexedDB: speed up index records deletion
index ede6224..12be644 100644 (file)
@@ -49,7 +49,7 @@ include_directories(${MALLOC_BENCH_INCLUDE_DIRECTORIES})
 SET(CMAKE_SKIP_BUILD_RPATH  TRUE)
 if (DEVELOPER_MODE)
     add_executable(MallocBench ${MALLOC_BENCH_SOURCES})
-    target_link_libraries(MallocBench ${CMAKE_THREAD_LIBS_INIT} ${MALLOC_BENCH_LIBRARIES} mbmalloc)
+    target_link_libraries(MallocBench ${MALLOC_BENCH_LIBRARIES} Threads::Threads mbmalloc)
     add_dependencies(MallocBench sysmalloc mbmalloc)
 endif ()
 
index b9c03ce..36149ec 100644 (file)
@@ -1,3 +1,15 @@
+2020-02-17  Don Olmstead  <don.olmstead@sony.com>
+
+        [CMake] Use builtin targets
+        https://bugs.webkit.org/show_bug.cgi?id=205166
+
+        Reviewed by Darin Adler.
+
+        * wtf/PlatformGTK.cmake:
+        * wtf/PlatformJSCOnly.cmake:
+        * wtf/PlatformPlayStation.cmake:
+        * wtf/PlatformWPE.cmake:
+
 2020-02-16  Fujii Hironori  <Hironori.Fujii@sony.com>
 
         Remove remaining WTF_EXPORT and WTF_IMPORT by replacing them with WTF_EXPORT_DECLARATION and WTF_IMPORT_DECLARATION
index 7822ab7..a8d9792 100644 (file)
@@ -55,11 +55,11 @@ else ()
 endif ()
 
 list(APPEND WTF_LIBRARIES
-    ${CMAKE_THREAD_LIBS_INIT}
     ${GLIB_GIO_LIBRARIES}
     ${GLIB_GOBJECT_LIBRARIES}
     ${GLIB_LIBRARIES}
-    ${ZLIB_LIBRARIES}
+    Threads::Threads
+    ZLIB::ZLIB
 )
 
 list(APPEND WTF_SYSTEM_INCLUDE_DIRECTORIES
index fd36edb..26ee88c 100644 (file)
@@ -115,5 +115,5 @@ else ()
 endif ()
 
 list(APPEND WTF_LIBRARIES
-    ${CMAKE_THREAD_LIBS_INIT}
+    Threads::Threads
 )
index 33ca049..34e3d3f 100644 (file)
@@ -18,10 +18,9 @@ list(APPEND WTF_SOURCES
 )
 
 list(APPEND WTF_LIBRARIES
-    ${CMAKE_THREAD_LIBS_INIT}
-
     ${C_STD_LIBRARY}
     ${KERNEL_LIBRARY}
+    Threads::Threads
 )
 
 # bmalloc is compiled as an OBJECT library so it is statically linked
index e18db51..e5a8ff4 100644 (file)
@@ -40,11 +40,11 @@ list(APPEND WTF_SOURCES
 )
 
 list(APPEND WTF_LIBRARIES
-    ${CMAKE_THREAD_LIBS_INIT}
     ${GLIB_GIO_LIBRARIES}
     ${GLIB_GOBJECT_LIBRARIES}
     ${GLIB_LIBRARIES}
-    ${ZLIB_LIBRARIES}
+    Threads::Threads
+    ZLIB::ZLIB
 )
 
 list(APPEND WTF_SYSTEM_INCLUDE_DIRECTORIES
index 178dff3..53295b6 100644 (file)
@@ -172,12 +172,6 @@ set(WebCore_PRIVATE_INCLUDE_DIRECTORIES
     "${WEBCORE_DIR}/xml/parser"
 )
 
-set(WebCore_SYSTEM_INCLUDE_DIRECTORIES
-    ${LIBXML2_INCLUDE_DIR}
-    ${LIBXSLT_INCLUDE_DIR}
-    ${ZLIB_INCLUDE_DIRS}
-)
-
 set(WebCore_IDL_INCLUDES
     css
     dom
@@ -1219,13 +1213,16 @@ set(WebCore_PLUG_INS_RESOURCES
 )
 
 set(WebCore_LIBRARIES
+    LibXml2::LibXml2
+    PAL
     SQLite::SQLite3
-    ${LIBXML2_LIBRARIES}
-    ${LIBXSLT_LIBRARIES}
-    ${ZLIB_LIBRARIES}
-    PAL${DEBUG_SUFFIX}
+    ZLIB::ZLIB
 )
 
+if (ENABLE_XSLT)
+    list(APPEND WebCore_LIBRARIES LibXslt::LibXslt)
+endif ()
+
 set(WebCoreTestSupport_LIBRARIES
     WebKit::JavaScriptCore
 )
index dda085f..334bb14 100644 (file)
@@ -1,3 +1,17 @@
+2020-02-17  Don Olmstead  <don.olmstead@sony.com>
+
+        [CMake] Use builtin targets
+        https://bugs.webkit.org/show_bug.cgi?id=205166
+
+        Reviewed by Darin Adler.
+
+        * CMakeLists.txt:
+        * PlatformGTK.cmake:
+        * PlatformMac.cmake:
+        * platform/Curl.cmake:
+        * platform/FreeType.cmake:
+        * platform/ImageDecoders.cmake:
+
 2020-02-17  Takashi Komori  <Takashi.Komori@sony.com>
 
         [Curl] Use shared single thread for WebSocket connections
index 1cf65fa..f7ad2bd 100644 (file)
@@ -1,3 +1,12 @@
+2020-02-17  Don Olmstead  <don.olmstead@sony.com>
+
+        [CMake] Use builtin targets
+        https://bugs.webkit.org/show_bug.cgi?id=205166
+
+        Reviewed by Darin Adler.
+
+        * pal/PlatformPlayStation.cmake:
+
 2020-02-16  Fujii Hironori  <Hironori.Fujii@sony.com>
 
         Remove remaining WTF_EXPORT and WTF_IMPORT by replacing them with WTF_EXPORT_DECLARATION and WTF_IMPORT_DECLARATION
index 610c798..67482d4 100644 (file)
@@ -9,6 +9,4 @@ list(APPEND PAL_SOURCES
     unix/LoggingUnix.cpp
 )
 
-list(APPEND PAL_SYSTEM_INCLUDE_DIRECTORIES ${OPENSSL_INCLUDE_DIR})
-
-list(APPEND PAL_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
+list(APPEND PAL_LIBRARIES OpenSSL::Crypto)
index cd92531..2ff6147 100644 (file)
@@ -94,7 +94,6 @@ list(APPEND WebCore_LIBRARIES
     ${X11_Xdamage_LIB}
     ${X11_Xrender_LIB}
     ${X11_Xt_LIB}
-    ${ZLIB_LIBRARIES}
 )
 
 if (USE_WPE_RENDERER)
@@ -114,7 +113,6 @@ list(APPEND WebCore_SYSTEM_INCLUDE_DIRECTORIES
     ${LIBSECRET_INCLUDE_DIRS}
     ${LIBTASN1_INCLUDE_DIRS}
     ${UPOWERGLIB_INCLUDE_DIRS}
-    ${ZLIB_INCLUDE_DIRS}
 )
 
 if (USE_WPE_RENDERER)
index 93350d7..fe11b76 100644 (file)
@@ -48,7 +48,6 @@ list(APPEND WebCore_LIBRARIES
     ${SQLITE3_LIBRARIES}
     ${SYSTEMCONFIGURATION_LIBRARY}
     ${XML2_LIBRARY}
-    ${ZLIB_LIBRARY}
 )
 
 add_definitions(-iframework ${APPLICATIONSERVICES_LIBRARY}/Versions/Current/Frameworks)
index eddb5fa..ecfde93 100644 (file)
@@ -72,13 +72,8 @@ list(APPEND WebCore_PRIVATE_FRAMEWORK_HEADERS
     platform/network/curl/SocketStreamHandleImpl.h
 )
 
-list(APPEND WebCore_SYSTEM_INCLUDE_DIRECTORIES
-    ${CURL_INCLUDE_DIRS}
-    ${OPENSSL_INCLUDE_DIR}
-)
-
 list(APPEND WebCore_LIBRARIES
+    CURL::libcurl
     LibPSL::LibPSL
-    ${CURL_LIBRARIES}
-    ${OPENSSL_LIBRARIES}
+    OpenSSL::SSL
 )
index bf482b2..d7c400a 100644 (file)
@@ -28,13 +28,9 @@ if (USE_CAIRO)
     )
 endif ()
 
-list(APPEND WebCore_SYSTEM_INCLUDE_DIRECTORIES
-    ${FREETYPE_INCLUDE_DIRS}
-)
-
 list(APPEND WebCore_LIBRARIES
-    ${FREETYPE_LIBRARIES}
     Fontconfig::Fontconfig
+    Freetype::Freetype
     HarfBuzz::HarfBuzz
     HarfBuzz::ICU
 )
index 33d6398..36af1b0 100644 (file)
@@ -30,13 +30,9 @@ list(APPEND WebCore_SOURCES
     platform/image-decoders/webp/WEBPImageDecoder.cpp
 )
 
-list(APPEND WebCore_SYSTEM_INCLUDE_DIRECTORIES
-    ${JPEG_INCLUDE_DIR}
-    ${PNG_INCLUDE_DIRS}
-)
 list(APPEND WebCore_LIBRARIES
-    ${JPEG_LIBRARIES}
-    ${PNG_LIBRARIES}
+    JPEG::JPEG
+    PNG::PNG
 )
 
 if (OpenJPEG_FOUND)
index cd1b39c..cce7e7f 100644 (file)
@@ -1,3 +1,14 @@
+2020-02-17  Don Olmstead  <don.olmstead@sony.com>
+
+        [CMake] Use builtin targets
+        https://bugs.webkit.org/show_bug.cgi?id=205166
+
+        Reviewed by Darin Adler.
+
+        * PlatformFTW.cmake:
+        * PlatformWPE.cmake:
+        * PlatformWin.cmake:
+
 2020-02-17  Alberto Garcia  <berto@igalia.com>
 
         [WPE] Change the QML plugin install path
index 4440cc0..2e46745 100644 (file)
@@ -169,7 +169,7 @@ list(APPEND WebKit_INCLUDE_DIRECTORIES
 )
 
 list(APPEND WebKit_PRIVATE_LIBRARIES
-    ${OPENSSL_LIBRARIES}
+    OpenSSL::SSL
     D2d1.lib
     D3d11.lib
     Dwrite
index 9110af5..2f720d7 100644 (file)
@@ -271,7 +271,6 @@ list(APPEND WebKit_INCLUDE_DIRECTORIES
 list(APPEND WebKit_SYSTEM_INCLUDE_DIRECTORIES
     ${ATK_INCLUDE_DIRS}
     ${ATK_BRIDGE_INCLUDE_DIRS}
-    ${FREETYPE_INCLUDE_DIRS}
     ${GLIB_INCLUDE_DIRS}
     ${GSTREAMER_INCLUDE_DIRS}
     ${LIBSECCOMP_INCLUDE_DIRS}
@@ -281,11 +280,11 @@ list(APPEND WebKit_SYSTEM_INCLUDE_DIRECTORIES
 
 list(APPEND WebKit_LIBRARIES
     Cairo::Cairo
+    Freetype::Freetype
     HarfBuzz::HarfBuzz
     HarfBuzz::ICU
     ${ATK_LIBRARIES}
     ${ATK_BRIDGE_LIBRARIES}
-    ${FREETYPE_LIBRARIES}
     ${GLIB_LIBRARIES}
     ${GLIB_GMODULE_LIBRARIES}
     ${GSTREAMER_LIBRARIES}
index b7755dc..5d9628d 100644 (file)
@@ -170,7 +170,7 @@ if (${WTF_PLATFORM_WIN_CAIRO})
     )
 
     list(APPEND WebKit_PRIVATE_LIBRARIES
-        ${OPENSSL_LIBRARIES}
+        OpenSSL::SSL
         mfuuid.lib
         strmiids.lib
     )
index 1a99857..9156ae2 100644 (file)
@@ -1,3 +1,13 @@
+2020-02-17  Don Olmstead  <don.olmstead@sony.com>
+
+        [CMake] Use builtin targets
+        https://bugs.webkit.org/show_bug.cgi?id=205166
+
+        Reviewed by Darin Adler.
+
+        * PlatformFTW.cmake:
+        * PlatformWin.cmake:
+
 2020-02-11  Fujii Hironori  <Hironori.Fujii@sony.com>
 
         Fix declarations marked by wrong export macros (WEBCORE_EXPORT and WTF_EXPORT)
index e09f977..14d93f4 100644 (file)
@@ -7,15 +7,11 @@ list(APPEND WebKitLegacy_SOURCES_Classes
     win/WebURLAuthenticationChallengeSenderCURL.cpp
 )
 list(APPEND WebKitLegacy_PRIVATE_LIBRARIES
-    ${OPENSSL_LIBRARIES}
+    OpenSSL::SSL
     D3D11.lib
     Dxgi.lib
     mfuuid.lib
     strmiids.lib
-    ${LIBXML2_LIBRARIES}
-    ${LIBXSLT_LIBRARIES}
-    ${SQLITE_LIBRARIES}
-    ${ZLIB_LIBRARIES}
 )
 
 add_custom_command(
index 523372c..5e3e50a 100644 (file)
@@ -8,7 +8,7 @@ if (${WTF_PLATFORM_WIN_CAIRO})
         win/WebURLAuthenticationChallengeSenderCURL.cpp
     )
     list(APPEND WebKitLegacy_PRIVATE_LIBRARIES
-        ${OPENSSL_LIBRARIES}
+        OpenSSL::SSL
         mfuuid.lib
         strmiids.lib
     )
@@ -23,10 +23,6 @@ else ()
         CoreText${DEBUG_SUFFIX}
         QuartzCore${DEBUG_SUFFIX}
         libdispatch${DEBUG_SUFFIX}
-        ${LIBXML2_LIBRARIES}
-        ${LIBXSLT_LIBRARIES}
-        ${SQLITE_LIBRARIES}
-        ${ZLIB_LIBRARIES}
     )
 endif ()
 
index 724de4b..7962e01 100644 (file)
@@ -17,6 +17,8 @@ if (NOT WEBKIT_LIBRARIES_DIR)
     endif ()
 endif ()
 
+set(WTF_PLATFORM_APPLE_WIN ON)
+
 include(OptionsWin)
 
 set(ENABLE_WEBCORE ON)
@@ -25,16 +27,15 @@ SET_AND_EXPOSE_TO_BUILD(USE_CF ON)
 SET_AND_EXPOSE_TO_BUILD(USE_CFURLCONNECTION ON)
 
 set(SQLite3_NAMES SQLite3${DEBUG_SUFFIX})
+
+find_package(ICU REQUIRED COMPONENTS data i18n uc)
+find_package(LibXml2 REQUIRED)
+find_package(LibXslt REQUIRED)
 find_package(SQLite3 REQUIRED)
+find_package(ZLIB REQUIRED)
 
 # Libraries where find_package does not work
 set(COREFOUNDATION_LIBRARY CoreFoundation${DEBUG_SUFFIX})
-set(LIBXML2_LIBRARIES libxml2${DEBUG_SUFFIX})
-set(LIBXSLT_LIBRARIES libxslt${DEBUG_SUFFIX})
-set(ZLIB_INCLUDE_DIRS "${WEBKIT_LIBRARIES_DIR}/include/zlib")
-set(ZLIB_LIBRARIES zdll${DEBUG_SUFFIX})
-
-include(target/icu)
 
 # Uncomment the following line to try the Direct2D backend.
 # set(USE_DIRECT2D 1)
index cc0eb18..b10554c 100644 (file)
@@ -100,9 +100,7 @@ find_package(ICU REQUIRED COMPONENTS data i18n uc)
 find_package(JPEG REQUIRED)
 find_package(LibPSL REQUIRED)
 find_package(LibXml2 REQUIRED)
-find_package(Nghttp2 REQUIRED)
 find_package(OpenSSL REQUIRED)
-find_package(Pixman REQUIRED)
 find_package(PNG REQUIRED)
 find_package(SQLite3 REQUIRED)
 find_package(Threads REQUIRED)
@@ -113,10 +111,6 @@ find_package(ZLIB REQUIRED)
 # TODO: Add a check for HAVE_RSA_PSS for support of CryptoAlgorithmRSA_PSS
 # https://bugs.webkit.org/show_bug.cgi?id=206635
 
-# Emulate what pkg-config would do with statically compiled libraries
-# FIXME: https://bugs.webkit.org/show_bug.cgi?id=192410
-list(APPEND CURL_LIBRARIES ${NGHTTP2_LIBRARIES})
-
 SET_AND_EXPOSE_TO_BUILD(HAVE_PTHREAD_SETNAME_NP ON)
 
 SET_AND_EXPOSE_TO_BUILD(USE_EXPORT_MACROS ON)
index 97b9f20..a27e27b 100644 (file)
@@ -51,6 +51,7 @@ if (NOT HAS_RUN_WEBKIT_COMMON)
     include(WebKitCCache)
     include(WebKitCompilerFlags)
     include(WebKitFeatures)
+    include(WebKitFindPackage)
 
     include(OptionsCommon)
     include(Options${PORT})
diff --git a/Source/cmake/WebKitFindPackage.cmake b/Source/cmake/WebKitFindPackage.cmake
new file mode 100644 (file)
index 0000000..a35d15a
--- /dev/null
@@ -0,0 +1,181 @@
+# This file overrides the behavior of find_package for WebKit projects.
+#
+# CMake provides Find modules that are used within WebKit. However there are ports
+# where the default behavior does not work and they need to explicitly set their
+# values. There are also targets available in later versions of CMake which are
+# nicer to work with.
+#
+# The purpose of this file is to make the behavior of find_package consistent
+# across ports and CMake versions. 
+
+# CMake provided targets. Remove wrappers whenever the minimum version is bumped.
+#
+# CURL::libcurl : since 3.12
+# ICU::<C> : since 3.7
+# Freetype::Freetype: since 3.10
+# LibXml2::LibXml2: since 3.12
+# LibXslt::LibXslt: since never
+# JPEG::JPEG: since 3.12
+# OpenSSL::SSL: Since 3.4
+# PNG::PNG : since 3.4
+# Threads::Threads: since 3.1
+# ZLIB::ZLIB: Since 3.1
+
+macro(find_package package)
+    set(_found_package OFF)
+
+    # Apple internal builds for Windows need to use _DEBUG_SUFFIX so manually
+    # find all third party libraries that have a corresponding Find module within
+    # CMake's distribution.
+    if (WTF_PLATFORM_APPLE_WIN)
+        set(_found_package ON)
+
+        if ("${package}" STREQUAL "ICU")
+            find_path(ICU_INCLUDE_DIR NAMES unicode/utypes.h)
+
+            find_library(ICU_I18N_LIBRARY NAMES libicuin${DEBUG_SUFFIX})
+            find_library(ICU_UC_LIBRARY NAMES libicuuc${DEBUG_SUFFIX})
+            # AppleWin does not provide a separate data library
+            find_library(ICU_DATA_LIBRARY NAMES libicuuc${DEBUG_SUFFIX})
+
+            if (NOT ICU_INCLUDE_DIR OR NOT ICU_I18N_LIBRARY OR NOT ICU_UC_LIBRARY)
+                message(FATAL_ERROR "Could not find ICU")
+            endif ()
+
+            set(ICU_INCLUDE_DIRS ${ICU_INCLUDE_DIR})
+            set(ICU_LIBRARIES ${ICU_I18N_LIBRARY} ${ICU_UC_LIBRARY})
+            set(ICU_FOUND ON)
+        elseif ("${package}" STREQUAL "LibXml2")
+            find_path(LIBXML2_INCLUDE_DIR NAMES libxml/xpath.h)
+            find_library(LIBXML2_LIBRARY NAMES libxml2${DEBUG_SUFFIX})
+
+            if (NOT LIBXML2_INCLUDE_DIR OR NOT LIBXML2_LIBRARY)
+                message(FATAL_ERROR "Could not find LibXml2")
+            endif ()
+
+            set(LIBXML2_INCLUDE_DIRS ${LIBXML2_INCLUDE_DIR})
+            set(LIBXML2_LIBRARIES ${LIBXML2_LIBRARY})
+            set(LIBXML2_FOUND ON)
+        elseif ("${package}" STREQUAL "LibXslt")
+            find_path(LIBXSLT_INCLUDE_DIR NAMES libxslt/xslt.h)
+            find_library(LIBXSLT_LIBRARY NAMES libxslt${DEBUG_SUFFIX})
+
+            if (NOT LIBXSLT_INCLUDE_DIR OR NOT LIBXSLT_LIBRARY)
+                message(FATAL_ERROR "Could not find LibXslt")
+            endif ()
+
+            find_library(LIBXSLT_EXSLT_LIBRARY NAMES libexslt${DEBUG_SUFFIX})
+
+            set(LIBXSLT_INCLUDE_DIRS ${LIBXSLT_INCLUDE_DIR})
+            set(LIBXSLT_LIBRARIES ${LIBXSLT_LIBRARY})
+            set(LIBXSLT_FOUND ON)
+        elseif ("${package}" STREQUAL "ZLIB")
+            find_path(ZLIB_INCLUDE_DIR NAMES zlib.h PATH_SUFFIXES zlib)
+            find_library(ZLIB_LIBRARY NAMES zdll${DEBUG_SUFFIX})
+
+            if (NOT ZLIB_INCLUDE_DIR OR NOT ZLIB_LIBRARY)
+                message(FATAL_ERROR "Could not find ZLIB")
+            endif ()
+
+            set(ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR})
+            set(ZLIB_LIBRARIES ${ZLIB_LIBRARY})
+            set(ZLIB_FOUND ON)
+        else ()
+           set(_found_package OFF)
+        endif ()
+    endif ()
+
+    # Apple builds have a unique location for ICU
+    if (APPLE AND "${package}" STREQUAL "ICU")
+        set(_found_package ON)
+
+        set(ICU_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/ICU/Headers)
+
+        # Apple just has a single dylib for ICU
+        set(ICU_I18N_LIBRARY /usr/lib/libicucore.dylib)
+        set(ICU_UC_LIBRARY /usr/lib/libicucore.dylib)
+        set(ICU_DATA_LIBRARY /usr/lib/libicucore.dylib)
+
+        set(ICU_LIBRARIES ${ICU_UC_LIBRARY})
+        set(ICU_FOUND ON)
+    endif ()
+
+    if (NOT _found_package)
+        _find_package(${ARGV})
+    endif ()
+
+    # Create targets that are present in later versions of CMake or are referenced above
+    if ("${package}" STREQUAL "CURL")
+        if (CURL_FOUND AND NOT TARGET CURL::libcurl)
+            add_library(CURL::libcurl UNKNOWN IMPORTED)
+            set_target_properties(CURL::libcurl PROPERTIES
+                IMPORTED_LOCATION "${CURL_LIBRARIES}"
+                INTERFACE_INCLUDE_DIRECTORIES "${CURL_INCLUDE_DIRS}"
+            )
+        endif ()
+    elseif ("${package}" STREQUAL "ICU")
+        if (ICU_FOUND AND NOT TARGET ICU::data)
+            add_library(ICU::data UNKNOWN IMPORTED)
+            set_target_properties(ICU::data PROPERTIES
+                IMPORTED_LOCATION "${ICU_DATA_LIBRARY}"
+                INTERFACE_INCLUDE_DIRECTORIES "${ICU_INCLUDE_DIRS}"
+                IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
+            )
+
+            add_library(ICU::i18n UNKNOWN IMPORTED)
+            set_target_properties(ICU::i18n PROPERTIES
+                IMPORTED_LOCATION "${ICU_I18N_LIBRARY}"
+                INTERFACE_INCLUDE_DIRECTORIES "${ICU_INCLUDE_DIRS}"
+                IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
+            )
+
+            add_library(ICU::uc UNKNOWN IMPORTED)
+            set_target_properties(ICU::uc PROPERTIES
+                IMPORTED_LOCATION "${ICU_UC_LIBRARY}"
+                INTERFACE_INCLUDE_DIRECTORIES "${ICU_INCLUDE_DIRS}"
+                IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
+            )
+        endif ()
+    elseif ("${package}" STREQUAL "LibXml2")
+        if (LIBXML2_FOUND AND NOT TARGET LibXml2::LibXml2)
+            add_library(LibXml2::LibXml2 UNKNOWN IMPORTED)
+            set_target_properties(LibXml2::LibXml2 PROPERTIES
+                IMPORTED_LOCATION "${LIBXML2_LIBRARIES}"
+                INTERFACE_INCLUDE_DIRECTORIES "${LIBXML2_INCLUDE_DIRS}"
+                INTERFACE_COMPILE_OPTIONS "${LIBXML2_DEFINITIONS}"
+            )
+        endif ()
+    elseif ("${package}" STREQUAL "LibXslt")
+        if (LIBXSLT_FOUND AND NOT TARGET LibXslt::LibXslt)
+            add_library(LibXslt::LibXslt UNKNOWN IMPORTED)
+            set_target_properties(LibXslt::LibXslt PROPERTIES
+                IMPORTED_LOCATION "${LIBXSLT_LIBRARIES}"
+                INTERFACE_INCLUDE_DIRECTORIES "${LIBXSLT_INCLUDE_DIR}"
+                INTERFACE_COMPILE_OPTIONS "${LIBXSLT_DEFINITIONS}"
+            )
+        endif ()
+        if (LIBXSLT_EXSLT_LIBRARY AND NOT TARGET LibXslt::LibExslt)
+            add_library(LibXslt::LibExslt UNKNOWN IMPORTED)
+            set_target_properties(LibXslt::LibExslt PROPERTIES
+                IMPORTED_LOCATION "${LIBXSLT_EXSLT_LIBRARY}"
+                INTERFACE_INCLUDE_DIRECTORIES "${LIBXSLT_INCLUDE_DIR}"
+            )
+        endif ()
+    elseif ("${package}" STREQUAL "JPEG")
+        if (JPEG_FOUND AND NOT TARGET JPEG::JPEG)
+            add_library(JPEG::JPEG UNKNOWN IMPORTED)
+            set_target_properties(JPEG::JPEG PROPERTIES
+                IMPORTED_LOCATION "${JPEG_LIBRARIES}"
+                INTERFACE_INCLUDE_DIRECTORIES "${JPEG_INCLUDE_DIR}"
+            )
+        endif ()
+    elseif ("${package}" STREQUAL "ZLIB")
+        if (ZLIB_FOUND AND NOT TARGET ZLIB::ZLIB)
+            add_library(ZLIB::ZLIB UNKNOWN IMPORTED)
+            set_target_properties(ZLIB::ZLIB PROPERTIES
+                IMPORTED_LOCATION "${ZLIB_LIBRARY}"
+                INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIRS}"
+            )
+        endif ()
+    endif ()
+endmacro()
diff --git a/Source/cmake/target/icu.cmake b/Source/cmake/target/icu.cmake
deleted file mode 100644 (file)
index 9da1ddf..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-# Apple ports provide their own ICU that can't be found by find_package(ICU).
-# This file will create targets that would be created by find_package(ICU).
-if (APPLE)
-    set(ICU_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/ICU/Headers)
-
-    # Apple just has a single dylib for ICU
-    set(ICU_I18N_LIBRARY /usr/lib/libicucore.dylib)
-    set(ICU_UC_LIBRARY /usr/lib/libicucore.dylib)
-    set(ICU_DATA_LIBRARY /usr/lib/libicucore.dylib)
-
-    set(ICU_LIBRARIES ${ICU_UC_LIBRARY})
-elseif (WIN32 AND NOT WTF_PLATFORM_WIN_CAIRO)
-    set(ICU_INCLUDE_DIRS ${WEBKIT_LIBRARIES_INCLUDE_DIR})
-
-    set(ICU_I18N_LIBRARY ${WEBKIT_LIBRARIES_LINK_DIR}/libicuin${DEBUG_SUFFIX}.lib)
-    set(ICU_UC_LIBRARY ${WEBKIT_LIBRARIES_LINK_DIR}/libicuuc${DEBUG_SUFFIX}.lib)
-
-    # AppleWin does not provide a separate data library
-    set(ICU_DATA_LIBRARY ${ICU_UC_LIBRARY})
-
-    set(ICU_LIBRARIES ${ICU_I18N_LIBRARY} ${ICU_UC_LIBRARY})
-else ()
-    message(FATAL_ERROR "Could not find ICU targets. Use find_package(ICU REQUIRED data i1n8 uc)")
-endif ()
-
-# Emulate ICU:: targets
-add_library(ICU::data UNKNOWN IMPORTED)
-set_target_properties(ICU::data PROPERTIES
-    INTERFACE_INCLUDE_DIRECTORIES "${ICU_INCLUDE_DIRS}"
-    IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
-    IMPORTED_LOCATION "${ICU_DATA_LIBRARY}"
-)
-
-add_library(ICU::i18n UNKNOWN IMPORTED)
-set_target_properties(ICU::i18n PROPERTIES
-    INTERFACE_INCLUDE_DIRECTORIES "${ICU_INCLUDE_DIRS}"
-    IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
-    IMPORTED_LOCATION "${ICU_I18N_LIBRARY}"
-)
-
-add_library(ICU::uc UNKNOWN IMPORTED)
-set_target_properties(ICU::uc PROPERTIES
-    INTERFACE_INCLUDE_DIRECTORIES "${ICU_INCLUDE_DIRS}"
-    IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
-    IMPORTED_LOCATION "${ICU_UC_LIBRARY}"
-)
index 892bd75..29146a2 100644 (file)
@@ -1,3 +1,12 @@
+2020-02-17  Don Olmstead  <don.olmstead@sony.com>
+
+        [CMake] Use builtin targets
+        https://bugs.webkit.org/show_bug.cgi?id=205166
+
+        Reviewed by Darin Adler.
+
+        * TestWebKitAPI/PlatformWin.cmake:
+
 2020-02-17  Aakash Jain  <aakash_jain@apple.com>
 
         [ews] add SetBuildSummary step for Windows EWS
index 94473f5..cae0f0b 100644 (file)
@@ -55,7 +55,7 @@ list(APPEND TestWebCore_LIBRARIES
 if (${WTF_PLATFORM_WIN_CAIRO})
     list(APPEND TestWebCore_LIBRARIES
         Cairo::Cairo
-        ${OPENSSL_LIBRARIES}
+        OpenSSL::SSL
         mfuuid
         strmiids
         vcruntime
@@ -73,10 +73,10 @@ else ()
         CFNetwork${DEBUG_SUFFIX}
         CoreGraphics${DEBUG_SUFFIX}
         CoreText${DEBUG_SUFFIX}
+        LibXslt::LibExslt
         QuartzCore${DEBUG_SUFFIX}
         WebKitQuartzCoreAdditions${DEBUG_SUFFIX}
         libdispatch${DEBUG_SUFFIX}
-        libexslt${DEBUG_SUFFIX}
     )
 endif ()