Link against atomic if needed (found on armel)
authorJochen Sprickerhof <git@jochen.sprickerhof.de>
Sat, 1 Feb 2020 23:22:36 +0000 (00:22 +0100)
committerJochen Sprickerhof <jspricke@debian.org>
Tue, 18 Aug 2020 18:22:29 +0000 (19:22 +0100)
Gbp-Pq: Name 0002-Link-against-atomic-if-needed-found-on-armel.patch

CMakeLists.txt
cmake/pcl_targets.cmake

index e5aa7f40a65cd2d929c91ada7af2015b2b91d55b..7de7093b3727aea903de7835f81b9e397f28f392 100644 (file)
@@ -60,6 +60,20 @@ elseif(MINGW)
   set(CMAKE_COMPILER_IS_MINGW 1)
 endif()
 
+# https://github.com/fish-shell/fish-shell/issues/5865
+include(CheckCXXSourceCompiles)
+CHECK_CXX_SOURCE_COMPILES("
+#include <atomic>
+struct big { int foo[64]; };
+std::atomic<big> x;
+int main() {
+   return x.load().foo[13];
+}"
+LIBATOMIC_NOT_NEEDED)
+IF (NOT LIBATOMIC_NOT_NEEDED)
+    SET(ATOMIC_LIBRARY "atomic")
+ENDIF()
+
 # Create a variable with expected default CXX flags
 # This will be used further down the road to check if the user explicitly provided CXX flags
 if(CMAKE_COMPILER_IS_MSVC)
index 88ce7f9072aaad3cc76b72a6fad39d4b7fa87d02..680b3ff3d165a578a539e1d322d75ca7d741351c 100644 (file)
@@ -229,7 +229,7 @@ function(PCL_ADD_LIBRARY _name)
   endif()
 
   if((UNIX AND NOT ANDROID) OR MINGW)
-    target_link_libraries(${_name} m)
+    target_link_libraries(${_name} m ${ATOMIC_LIBRARY})
   endif()
 
   if(MINGW)