[CMake] WebKit should link to WebCore as a PRIVATE library if WebCore is a static...
authorHironori.Fujii@sony.com <Hironori.Fujii@sony.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 9 Apr 2018 02:58:40 +0000 (02:58 +0000)
committerHironori.Fujii@sony.com <Hironori.Fujii@sony.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 9 Apr 2018 02:58:40 +0000 (02:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=184127

Reviewed by Konstantin Tokarev.

.:

Building TestWebKitLib on Windows causes a linkage error of
multiply defined symbols because TestWebKitLib links to
both WebCore and WebKit. TestWebKitLib explicitly links only with
WebKit, But, WebCore is propagated because WebKit links WebCore as
public.

* Source/cmake/OptionsGTK.cmake (ADD_WHOLE_ARCHIVE_TO_LIBRARIES):
Do not wrap PRIVATE and PUBLIC keywords with -Wl,--whole-archive.

Source/WebCore:

No new tests (No behaviour changes).

* CMakeLists.txt: Added a interface library WebCoreHeaderInterface.

Source/WebKit:

* CMakeLists.txt: Link with WebCore as private,
WebCoreHeaderInterface as public to WebKit if WebCore is a static
library.
* CMakeLists.txt:
* PlatformGTK.cmake: Added PRIVATE keyword for WebKit_LIBRARIES.
* PlatformWPE.cmake: Ditto.
* PlatformWin.cmake: Ditto.

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

ChangeLog
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebKit/CMakeLists.txt
Source/WebKit/ChangeLog
Source/WebKit/PlatformGTK.cmake
Source/WebKit/PlatformWPE.cmake
Source/WebKit/PlatformWin.cmake
Source/cmake/OptionsGTK.cmake

index 8016166..9af0aec 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2018-04-08  Fujii Hironori  <Hironori.Fujii@sony.com>
+
+        [CMake] WebKit should link to WebCore as a PRIVATE library if WebCore is a static library
+        https://bugs.webkit.org/show_bug.cgi?id=184127
+
+        Reviewed by Konstantin Tokarev.
+
+        Building TestWebKitLib on Windows causes a linkage error of
+        multiply defined symbols because TestWebKitLib links to
+        both WebCore and WebKit. TestWebKitLib explicitly links only with
+        WebKit, But, WebCore is propagated because WebKit links WebCore as
+        public.
+
+        * Source/cmake/OptionsGTK.cmake (ADD_WHOLE_ARCHIVE_TO_LIBRARIES):
+        Do not wrap PRIVATE and PUBLIC keywords with -Wl,--whole-archive.
+
 2018-04-08  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         [WPE][GTK] Remove applicationDirectoryPath() and sharedResourcePath()
index 0d1ee7f..7a8a12d 100644 (file)
@@ -1961,6 +1961,14 @@ if (CMAKE_COMPILER_IS_GNUCXX AND "${LOWERCASE_CMAKE_HOST_SYSTEM_PROCESSOR}" MATC
     WEBKIT_ADD_TARGET_CXX_FLAGS(WebCore -fno-tree-sra)
 endif ()
 
+# Include paths of WebCore doesn't propagate to targets using WebKit
+# because WebCore is linked to WebKit as a PRIVATE library. Forwarding
+# headers generated by generate-forwarding-headers.pl needs include
+# paths of WebCore.
+add_library(WebCoreHeaderInterface INTERFACE)
+target_include_directories(WebCoreHeaderInterface INTERFACE ${WebCore_INCLUDE_DIRECTORIES})
+target_link_libraries(WebCoreHeaderInterface INTERFACE ${WebCore_LIBRARIES})
+
 if (MSVC)
     WEBKIT_ADD_PRECOMPILED_HEADER("WebCoreTestSupportPrefix.h" "testing/js/WebCoreTestSupportPrefix.cpp" WebCoreTestSupport_SOURCES)
 endif ()
@@ -1995,7 +2003,7 @@ if (ENABLE_GRAPHICS_CONTEXT_3D AND NOT WIN32)
         "${THIRDPARTY_DIR}/ANGLE/src"
         "${THIRDPARTY_DIR}/ANGLE/src/common/third_party/base"
     )
-    list(APPEND WebCore_LIBRARIES ANGLESupport)
+    target_link_libraries(WebCore ANGLESupport)
 
     if (COMPILER_IS_GCC_OR_CLANG)
         WEBKIT_ADD_TARGET_CXX_FLAGS(ANGLESupport -Wno-implicit-fallthrough
@@ -2007,7 +2015,6 @@ if (ENABLE_GRAPHICS_CONTEXT_3D AND NOT WIN32)
     endif ()
 endif ()
 
-target_link_libraries(WebCore ${WebCore_LIBRARIES})
 
 if (${WebCore_LIBRARY_TYPE} MATCHES "SHARED")
     set_target_properties(WebCore PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR})
index 7ae5549..4a67535 100644 (file)
@@ -1,3 +1,14 @@
+2018-04-08  Fujii Hironori  <Hironori.Fujii@sony.com>
+
+        [CMake] WebKit should link to WebCore as a PRIVATE library if WebCore is a static library
+        https://bugs.webkit.org/show_bug.cgi?id=184127
+
+        Reviewed by Konstantin Tokarev.
+
+        No new tests (No behaviour changes).
+
+        * CMakeLists.txt: Added a interface library WebCoreHeaderInterface.
+
 2018-04-08  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         Use alignas instead of compiler-specific attributes
index 705a6f4..4369094 100644 (file)
@@ -726,9 +726,16 @@ set(WebKit_MESSAGES_IN_FILES
     WebProcess/WebStorage/StorageAreaMap.messages.in
 )
 
-set(WebKit_LIBRARIES
-    WebCore
-)
+if (${WebCore_LIBRARY_TYPE} STREQUAL STATIC)
+    # Link with WebCore as PRIVATE not to propagate WebCore to all users of WebKit.
+    set(WebKit_LIBRARIES
+        PRIVATE WebCore
+        PUBLIC WebCoreHeaderInterface
+    )
+else ()
+    # All users of WebKit need to link WebCore if WebCore is a shared library.
+    set(WebKit_LIBRARIES PUBLIC WebCore)
+endif ()
 
 set(WebProcess_LIBRARIES
     WebKit
@@ -755,7 +762,7 @@ if (ENABLE_GRAPHICS_CONTEXT_3D)
             ${LIBEPOXY_INCLUDE_DIRS}
         )
         list(APPEND WebKit_LIBRARIES
-            ${LIBEPOXY_LIBRARIES}
+            PRIVATE ${LIBEPOXY_LIBRARIES}
         )
         add_definitions(${LIBEPOXY_DEFINITIONS})
     else ()
@@ -764,7 +771,7 @@ if (ENABLE_GRAPHICS_CONTEXT_3D)
                 ${OPENGL_INCLUDE_DIRS}
             )
             list(APPEND WebKit_LIBRARIES
-                ${OPENGL_LIBRARIES}
+                PRIVATE ${OPENGL_LIBRARIES}
             )
             add_definitions(${OPENGL_DEFINITIONS})
         elseif (USE_OPENGL_ES)
@@ -772,7 +779,7 @@ if (ENABLE_GRAPHICS_CONTEXT_3D)
                 ${OPENGLES2_INCLUDE_DIRS}
             )
             list(APPEND WebKit_LIBRARIES
-                ${OPENGLES2_LIBRARIES}
+                PRIVATE ${OPENGLES2_LIBRARIES}
             )
             add_definitions(${OPENGLES2_DEFINITIONS})
         endif ()
@@ -782,7 +789,7 @@ if (ENABLE_GRAPHICS_CONTEXT_3D)
                 ${EGL_INCLUDE_DIRS}
             )
             list(APPEND WebKit_LIBRARIES
-                ${EGL_LIBRARIES}
+                PRIVATE ${EGL_LIBRARIES}
             )
             add_definitions(${EGL_DEFINITIONS})
         endif ()
@@ -812,7 +819,7 @@ if (COMPILER_IS_GCC_OR_CLANG)
         set(CMAKE_REQUIRED_LIBRARIES atomic)
         check_cxx_source_compiles("${ATOMIC_TEST_SOURCE}" ATOMIC_INT64_REQUIRES_LIBATOMIC)
         if (ATOMIC_INT64_REQUIRES_LIBATOMIC)
-            list(APPEND WebKit_LIBRARIES atomic)
+            list(APPEND WebKit_LIBRARIES PRIVATE atomic)
         endif ()
         unset(CMAKE_REQUIRED_LIBRARIES)
     endif ()
@@ -824,7 +831,7 @@ if (UNIX)
         set(CMAKE_REQUIRED_LIBRARIES rt)
         check_function_exists(shm_open SHM_OPEN_REQUIRES_LIBRT)
         if (SHM_OPEN_REQUIRES_LIBRT)
-            list(APPEND WebKit_LIBRARIES rt)
+            list(APPEND WebKit_LIBRARIES PRIVATE rt)
         endif ()
         unset(CMAKE_REQUIRED_LIBRARIES)
     endif ()
index ee0b1d1..1cdba45 100644 (file)
@@ -1,3 +1,18 @@
+2018-04-08  Fujii Hironori  <Hironori.Fujii@sony.com>
+
+        [CMake] WebKit should link to WebCore as a PRIVATE library if WebCore is a static library
+        https://bugs.webkit.org/show_bug.cgi?id=184127
+
+        Reviewed by Konstantin Tokarev.
+
+        * CMakeLists.txt: Link with WebCore as private,
+        WebCoreHeaderInterface as public to WebKit if WebCore is a static
+        library.
+        * CMakeLists.txt:
+        * PlatformGTK.cmake: Added PRIVATE keyword for WebKit_LIBRARIES.
+        * PlatformWPE.cmake: Ditto.
+        * PlatformWin.cmake: Ditto.
+
 2018-04-08  Andy Estes  <aestes@apple.com>
 
         [iOS] WKContentView and WKLegacyPDFView should share application state tracking logic
index 0eeeb27..e39525a 100644 (file)
@@ -456,16 +456,18 @@ set(SharedWebKitLibraries
     ${WebKit_LIBRARIES}
 )
 
-
 list(APPEND WebKit_LIBRARIES
-    # WebCore should be specifed before and after WebCorePlatformGTK
-    WebCorePlatformGTK WebCore
-    ${GTK_UNIX_PRINT_LIBRARIES}
+    PRIVATE
+        WebCorePlatformGTK
+        ${GTK_UNIX_PRINT_LIBRARIES}
 )
 
+# WebCore should be specifed before and after WebCorePlatformGTK
+list(APPEND WebKit_LIBRARIES PRIVATE WebCore)
+
 if (LIBNOTIFY_FOUND)
 list(APPEND WebKit_LIBRARIES
-    ${LIBNOTIFY_LIBRARIES}
+    PRIVATE ${LIBNOTIFY_LIBRARIES}
 )
 endif ()
 
@@ -674,7 +676,7 @@ if (ENABLE_PLUGIN_PROCESS_GTK2)
 
     set(WebKitPluginProcess2_LIBRARIES
         ${SharedWebKitLibraries}
-        WebCorePlatformGTK2
+        PRIVATE WebCorePlatformGTK2
     )
     ADD_WHOLE_ARCHIVE_TO_LIBRARIES(WebKitPluginProcess2_LIBRARIES)
     target_link_libraries(WebKitPluginProcess2 ${WebKitPluginProcess2_LIBRARIES})
index 823d416..dfb7b46 100644 (file)
@@ -286,13 +286,14 @@ list(APPEND WebKit_SYSTEM_INCLUDE_DIRECTORIES
 )
 
 list(APPEND WebKit_LIBRARIES
-    ${CAIRO_LIBRARIES}
-    ${FREETYPE2_LIBRARIES}
-    ${GLIB_LIBRARIES}
-    ${GSTREAMER_LIBRARIES}
-    ${HARFBUZZ_LIBRARIES}
-    ${LIBSOUP_LIBRARIES}
-    ${WPE_LIBRARIES}
+    PRIVATE
+        ${CAIRO_LIBRARIES}
+        ${FREETYPE2_LIBRARIES}
+        ${GLIB_LIBRARIES}
+        ${GSTREAMER_LIBRARIES}
+        ${HARFBUZZ_LIBRARIES}
+        ${LIBSOUP_LIBRARIES}
+        ${WPE_LIBRARIES}
 )
 
 WEBKIT_BUILD_INSPECTOR_GRESOURCES(${DERIVED_SOURCES_WEBINSPECTORUI_DIR})
index 56e150e..a508063 100644 (file)
@@ -129,9 +129,10 @@ if (${WTF_PLATFORM_WIN_CAIRO})
     )
 
     list(APPEND WebKit_LIBRARIES
-        ${OPENSSL_LIBRARIES}
-        mfuuid.lib
-        strmiids.lib
+        PRIVATE
+            ${OPENSSL_LIBRARIES}
+            mfuuid.lib
+            strmiids.lib
     )
 endif ()
 
index e694dff..4188a67 100644 (file)
@@ -409,10 +409,15 @@ macro(ADD_WHOLE_ARCHIVE_TO_LIBRARIES _list_name)
     if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
         list(APPEND ${_list_name} -Wl,-all_load)
     else ()
-        foreach (library IN LISTS ${_list_name})
-          list(APPEND ${_list_name}_TMP -Wl,--whole-archive ${library} -Wl,--no-whole-archive)
+        set(_tmp)
+        foreach (item IN LISTS ${_list_name})
+            if ("${item}" STREQUAL "PRIVATE" OR "${item}" STREQUAL "PUBLIC")
+                list(APPEND _tmp "${item}")
+            else ()
+                list(APPEND _tmp -Wl,--whole-archive "${item}" -Wl,--no-whole-archive)
+            endif ()
         endforeach ()
-        set(${_list_name} "${${_list_name}_TMP}")
+        set(${_list_name} ${_tmp})
     endif ()
 endmacro()