Build wtf/Atomics.cpp only if needed
authorAlberto Garcia <berto@igalia.com>
Tue, 27 Jun 2017 07:29:49 +0000 (08:29 +0100)
committerAlberto Garcia <berto@igalia.com>
Tue, 27 Jun 2017 07:29:49 +0000 (08:29 +0100)
===================================================================

Gbp-Pq: Name fix-ftbfs-armel.patch

Source/WTF/wtf/CMakeLists.txt

index 356c927aa9ac5cbee22464220c7e2a8d1f549fe5..07b4c3bd1712a5af67732b065ae2c8557ed75aab 100644 (file)
@@ -182,7 +182,6 @@ set(WTF_HEADERS
 
 set(WTF_SOURCES
     Assertions.cpp
-    Atomics.cpp
     AutomaticThread.cpp
     BitVector.cpp
     ClockType.cpp
@@ -304,6 +303,16 @@ if (NOT USE_SYSTEM_MALLOC)
     list(APPEND WTF_LIBRARIES bmalloc)
 endif ()
 
+file(WRITE ${CMAKE_BINARY_DIR}/test_atomics.cpp
+     "int main(void)\n"
+     "{ long long x = 1; return (int) __sync_add_and_fetch_8(&x, 1); }\n")
+try_compile(ATOMICS_BUILD_SUCCEEDED ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/test_atomics.cpp)
+message(STATUS "Found __sync_add_and_fetch_8(): ${ATOMICS_BUILD_SUCCEEDED}")
+if (NOT ATOMICS_BUILD_SUCCEEDED)
+    list(APPEND WTF_SOURCES Atomics.cpp)
+endif ()
+file(REMOVE ${CMAKE_BINARY_DIR}/test_atomics.cpp)
+
 list(APPEND WTF_SOURCES
     unicode/icu/CollatorICU.cpp
 )