summaryrefslogtreecommitdiffstats
path: root/cmake/FindAtomic.cmake
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2020-04-28 17:33:29 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2020-04-29 23:08:32 +0200
commit062b50abff6a3cb2319ade41dddf76caa36f27e3 (patch)
tree7a0ec6ab28500b2a84d6edcc240d9bc6a309549d /cmake/FindAtomic.cmake
parent317cfb677464a9610e4b46971e508b90f59b90f6 (diff)
CMake: Namespace all our IMPORTED targets
CMake IMPORTED targets should be namespaced so that CMake knows that the name refers to a target and not a file. Use the existing WrapXXX naming scheme where applicable. Fixes: QTBUG-83773 Change-Id: I5b0b722c811200c56c260c69e76940a625228769 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake/FindAtomic.cmake')
-rw-r--r--cmake/FindAtomic.cmake44
1 files changed, 0 insertions, 44 deletions
diff --git a/cmake/FindAtomic.cmake b/cmake/FindAtomic.cmake
deleted file mode 100644
index 91cee62046..0000000000
--- a/cmake/FindAtomic.cmake
+++ /dev/null
@@ -1,44 +0,0 @@
-# We can't create the same interface imported target multiple times, CMake will complain if we do
-# that. This can happen if the find_package call is done in multiple different subdirectories.
-if(TARGET Atomic)
- set(Atomic_FOUND ON)
- return()
-endif()
-
-include(CheckCXXSourceCompiles)
-
-set (atomic_test_sources "#include <atomic>
-#include <cstdint>
-
-void test(volatile std::atomic<std::int64_t> &a)
-{
- std::int64_t v = a.load(std::memory_order_acquire);
- while (!a.compare_exchange_strong(v, v + 1,
- std::memory_order_acq_rel,
- std::memory_order_acquire)) {
- v = a.exchange(v - 1);
- }
- a.store(v + 1, std::memory_order_release);
-}
-
-int main(int, char **)
-{
- void *ptr = (void*)0xffffffc0; // any random pointer
- test(*reinterpret_cast<std::atomic<std::int64_t> *>(ptr));
- return 0;
-}")
-
-check_cxx_source_compiles("${atomic_test_sources}" HAVE_STDATOMIC)
-if(NOT HAVE_STDATOMIC)
- set(_req_libraries "${CMAKE_REQUIRE_LIBRARIES}")
- set(CMAKE_REQUIRE_LIBRARIES "atomic")
- check_cxx_source_compiles("${atomic_test_sources}" HAVE_STDATOMIC_WITH_LIB)
- set(CMAKE_REQUIRE_LIBRARIES "${_req_libraries}")
-endif()
-
-add_library(Atomic INTERFACE IMPORTED)
-if(HAVE_STDATOMIC_WITH_LIB)
- target_link_libraries(Atomic INTERFACE atomic)
-endif()
-
-set(Atomic_FOUND 1)