Changeset 218888 in webkit


Ignore:
Timestamp:
Jun 28, 2017 1:02:07 PM (7 years ago)
Author:
Konstantin Tokarev
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:
Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/CMakeLists.txt

    r218455 r218888  
     1include(CheckCXXSourceCompiles)
     2include(CheckFunctionExists)
     3
    14set_property(DIRECTORY . PROPERTY FOLDER "WebKit2")
    25
     
    714717endif ()
    715718
    716 # librt is needed for shm_open on Linux.
    717 find_library(LIBRT_LIBRARIES NAMES rt)
    718 mark_as_advanced(LIBRT_LIBRARIES)
    719 if (LIBRT_LIBRARIES)
    720     list(APPEND WebKit2_LIBRARIES ${LIBRT_LIBRARIES})
     719if (COMPILER_IS_GCC_OR_CLANG)
     720    set(ATOMIC_TEST_SOURCE
     721    "
     722        #include <atomic>
     723        int main() { std::atomic<int64_t> i(0); i++; return 0; }
     724    "
     725    )
     726    check_cxx_source_compiles("${ATOMIC_TEST_SOURCE}" ATOMIC_INT64_IS_BUILTIN)
     727    if (NOT ATOMIC_INT64_IS_BUILTIN)
     728        set(CMAKE_REQUIRED_LIBRARIES atomic)
     729        check_cxx_source_compiles("${ATOMIC_TEST_SOURCE}" ATOMIC_INT64_REQUIRES_LIBATOMIC)
     730        if (ATOMIC_INT64_REQUIRES_LIBATOMIC)
     731            list(APPEND WebKit2_LIBRARIES atomic)
     732        endif ()
     733        unset(CMAKE_REQUIRED_LIBRARIES)
     734    endif ()
     735endif ()
     736
     737if (UNIX)
     738    check_function_exists(shm_open SHM_OPEN_EXISTS)
     739    if (NOT SHM_OPEN_EXISTS)
     740        set(CMAKE_REQUIRED_LIBRARIES rt)
     741        check_function_exists(shm_open SHM_OPEN_REQUIRES_LIBRT)
     742        if (SHM_OPEN_REQUIRES_LIBRT)
     743            list(APPEND WebKit2_LIBRARIES rt)
     744        endif ()
     745    endif ()
    721746endif ()
    722747
  • trunk/Source/WebKit2/ChangeLog

    r218886 r218888  
     12017-06-28  Konstantin Tokarev  <annulen@yandex.ru>
     2
     3        [cmake] Improve configuration tests for librt and libatomic
     4        https://bugs.webkit.org/show_bug.cgi?id=173921
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        1. Both tests are converted to use specialized CMake modules
     9        2. Both libraries are now linked only if they are really needed and usable
     10           by compiler
     11        3. librt is no more required to be detected by find_library(), which may fail
     12           in case of cross-compilation
     13        4. libatomic test moved to port-independent CMakeLists.txt
     14
     15        * CMakeLists.txt:
     16        * PlatformGTK.cmake:
     17
    1182017-06-28  Alex Christensen  <achristensen@webkit.org>
    219
  • trunk/Source/WebKit2/PlatformGTK.cmake

    r218841 r218888  
    845845)
    846846
    847 file(WRITE ${CMAKE_BINARY_DIR}/test_atomic.cpp
    848      "#include <atomic>\n"
    849      "int main() { std::atomic<int64_t> i(0); i++; return 0; }\n")
    850 try_compile(ATOMIC_BUILD_SUCCEEDED ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/test_atomic.cpp)
    851 if (NOT ATOMIC_BUILD_SUCCEEDED)
    852     list(APPEND WebKit2_LIBRARIES atomic)
    853 endif ()
    854 file(REMOVE ${CMAKE_BINARY_DIR}/test_atomic.cpp)
    855 
    856847set(SharedWebKit2Libraries
    857848    ${WebKit2_LIBRARIES}
Note: See TracChangeset for help on using the changeset viewer.