Title: [218888] trunk/Source/WebKit2
Revision
218888
Author
annu...@yandex.ru
Date
2017-06-28 13:02:07 -0700 (Wed, 28 Jun 2017)

Log Message

[cmake] Improve configuration tests for librt and libatomic
https://bugs.webkit.org/show_bug.cgi?id=173921

Reviewed by Michael Catanzaro.

1. Both tests are converted to use specialized CMake modules
2. Both libraries are now linked only if they are really needed and usable
   by compiler
3. librt is no more required to be detected by find_library(), which may fail
   in case of cross-compilation
4. libatomic test moved to port-independent CMakeLists.txt

* CMakeLists.txt:
* PlatformGTK.cmake:

Modified Paths

Diff

Modified: trunk/Source/WebKit2/CMakeLists.txt (218887 => 218888)


--- trunk/Source/WebKit2/CMakeLists.txt	2017-06-28 19:53:46 UTC (rev 218887)
+++ trunk/Source/WebKit2/CMakeLists.txt	2017-06-28 20:02:07 UTC (rev 218888)
@@ -1,3 +1,6 @@
+include(CheckCXXSourceCompiles)
+include(CheckFunctionExists)
+
 set_property(DIRECTORY . PROPERTY FOLDER "WebKit2")
 
 set(WebKit2_INCLUDE_DIRECTORIES
@@ -713,13 +716,35 @@
     set(_javascript_Core_SCRIPTS_DIR "${FORWARDING_HEADERS_DIR}/_javascript_Core/Scripts")
 endif ()
 
-# librt is needed for shm_open on Linux.
-find_library(LIBRT_LIBRARIES NAMES rt)
-mark_as_advanced(LIBRT_LIBRARIES)
-if (LIBRT_LIBRARIES)
-    list(APPEND WebKit2_LIBRARIES ${LIBRT_LIBRARIES})
+if (COMPILER_IS_GCC_OR_CLANG)
+    set(ATOMIC_TEST_SOURCE
+    "
+        #include <atomic>
+        int main() { std::atomic<int64_t> i(0); i++; return 0; }
+    "
+    )
+    check_cxx_source_compiles("${ATOMIC_TEST_SOURCE}" ATOMIC_INT64_IS_BUILTIN)
+    if (NOT ATOMIC_INT64_IS_BUILTIN)
+        set(CMAKE_REQUIRED_LIBRARIES atomic)
+        check_cxx_source_compiles("${ATOMIC_TEST_SOURCE}" ATOMIC_INT64_REQUIRES_LIBATOMIC)
+        if (ATOMIC_INT64_REQUIRES_LIBATOMIC)
+            list(APPEND WebKit2_LIBRARIES atomic)
+        endif ()
+        unset(CMAKE_REQUIRED_LIBRARIES)
+    endif ()
 endif ()
 
+if (UNIX)
+    check_function_exists(shm_open SHM_OPEN_EXISTS)
+    if (NOT SHM_OPEN_EXISTS)
+        set(CMAKE_REQUIRED_LIBRARIES rt)
+        check_function_exists(shm_open SHM_OPEN_REQUIRES_LIBRT)
+        if (SHM_OPEN_REQUIRES_LIBRT)
+            list(APPEND WebKit2_LIBRARIES rt)
+        endif ()
+    endif ()
+endif ()
+
 macro(ADD_WEBKIT2_PREFIX_HEADER _target)
     if (WebKit2_USE_PREFIX_HEADER)
         get_target_property(OLD_COMPILE_FLAGS ${_target} COMPILE_FLAGS)

Modified: trunk/Source/WebKit2/ChangeLog (218887 => 218888)


--- trunk/Source/WebKit2/ChangeLog	2017-06-28 19:53:46 UTC (rev 218887)
+++ trunk/Source/WebKit2/ChangeLog	2017-06-28 20:02:07 UTC (rev 218888)
@@ -1,3 +1,20 @@
+2017-06-28  Konstantin Tokarev  <annu...@yandex.ru>
+
+        [cmake] Improve configuration tests for librt and libatomic
+        https://bugs.webkit.org/show_bug.cgi?id=173921
+
+        Reviewed by Michael Catanzaro.
+
+        1. Both tests are converted to use specialized CMake modules
+        2. Both libraries are now linked only if they are really needed and usable
+           by compiler
+        3. librt is no more required to be detected by find_library(), which may fail
+           in case of cross-compilation
+        4. libatomic test moved to port-independent CMakeLists.txt
+
+        * CMakeLists.txt:
+        * PlatformGTK.cmake:
+
 2017-06-28  Alex Christensen  <achristen...@webkit.org>
 
         Fix CMake build.

Modified: trunk/Source/WebKit2/PlatformGTK.cmake (218887 => 218888)


--- trunk/Source/WebKit2/PlatformGTK.cmake	2017-06-28 19:53:46 UTC (rev 218887)
+++ trunk/Source/WebKit2/PlatformGTK.cmake	2017-06-28 20:02:07 UTC (rev 218888)
@@ -844,15 +844,6 @@
     DatabaseProcess/EntryPoint/unix/DatabaseProcessMain.cpp
 )
 
-file(WRITE ${CMAKE_BINARY_DIR}/test_atomic.cpp
-     "#include <atomic>\n"
-     "int main() { std::atomic<int64_t> i(0); i++; return 0; }\n")
-try_compile(ATOMIC_BUILD_SUCCEEDED ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/test_atomic.cpp)
-if (NOT ATOMIC_BUILD_SUCCEEDED)
-    list(APPEND WebKit2_LIBRARIES atomic)
-endif ()
-file(REMOVE ${CMAKE_BINARY_DIR}/test_atomic.cpp)
-
 set(SharedWebKit2Libraries
     ${WebKit2_LIBRARIES}
 )
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to