From: =?utf-8?q?Timo_R=C3=B6hling?= <roehling@debian.org>
Date: Sun, 13 Jun 2021 22:58:10 +0200
Subject: Link tests against libatomic where needed

---
 cmake/modules/FindAtomic.cmake             | 6 +++++-
 test/unittest/CMakeLists.txt               | 2 ++
 test/unittest/rtps/security/CMakeLists.txt | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/cmake/modules/FindAtomic.cmake b/cmake/modules/FindAtomic.cmake
index 35ca4af..56f76ac 100644
--- a/cmake/modules/FindAtomic.cmake
+++ b/cmake/modules/FindAtomic.cmake
@@ -15,10 +15,14 @@ set(ATOMIC_TEST_CODE
     #include <atomic>
     #include <cstdint>
 
+    std::atomic<bool> b;
+
     int main()
     {
         using namespace std;
 
+	bool b2 = true;
+
         volatile atomic_ullong i(0xcafebabedeadbeeful);
         i += 0xfeedbadc0de8f00dul;
 
@@ -32,7 +36,7 @@ set(ATOMIC_TEST_CODE
         atomic<Pointer> pointer;
         pointer = dummy;
 
-        return 0;
+        return !b.compare_exchange_strong(b2, false);
     }"
 )
 
diff --git a/test/unittest/CMakeLists.txt b/test/unittest/CMakeLists.txt
index b2f8d4e..2f67bdd 100644
--- a/test/unittest/CMakeLists.txt
+++ b/test/unittest/CMakeLists.txt
@@ -12,6 +12,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+find_package(Atomic MODULE)
+
 add_compile_definitions(FASTDDS_NO_LIB)
 
 add_subdirectory(cmake)
diff --git a/test/unittest/rtps/security/CMakeLists.txt b/test/unittest/rtps/security/CMakeLists.txt
index 45371cc..f0d7c8e 100644
--- a/test/unittest/rtps/security/CMakeLists.txt
+++ b/test/unittest/rtps/security/CMakeLists.txt
@@ -105,5 +105,6 @@ target_link_libraries(SecurityAuthentication
     fastdds::log
     GTest::gmock
     ${OPENSSL_LIBRARIES}
+    eProsima_atomic
     )
 gtest_discover_tests(SecurityAuthentication)
