summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2019-06-05 14:28:31 +0200
committerKevin Funk <kevin.funk@kdab.com>2019-06-05 12:30:47 +0000
commitace549587073d387823815b02ec85a28da408844 (patch)
tree0e0ff29a17b62ded3086ba5560c2dfc4838b2e45
parent37467028bb07c14311ac2cf9741c274d5b44b388 (diff)
Fix a few of the Wrap modules to protect against double creation of
targets. This created issues when trying to build standalone examples. Change-Id: Iaaea2b537793ae25fbf3143cc205574446aa4ad1 Reviewed-by: Kevin Funk <kevin.funk@kdab.com>
-rw-r--r--cmake/FindAtomic.cmake7
-rw-r--r--cmake/FindWrapDoubleConversion.cmake7
-rw-r--r--cmake/FindWrapRt.cmake7
3 files changed, 21 insertions, 0 deletions
diff --git a/cmake/FindAtomic.cmake b/cmake/FindAtomic.cmake
index b4580067ca..91cee62046 100644
--- a/cmake/FindAtomic.cmake
+++ b/cmake/FindAtomic.cmake
@@ -1,3 +1,10 @@
+# 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>
diff --git a/cmake/FindWrapDoubleConversion.cmake b/cmake/FindWrapDoubleConversion.cmake
index 1164f6ba44..9c804a3eec 100644
--- a/cmake/FindWrapDoubleConversion.cmake
+++ b/cmake/FindWrapDoubleConversion.cmake
@@ -1,3 +1,10 @@
+# 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 WrapDoubleConversion::WrapDoubleConversion)
+ set(WrapDoubleConversion_FOUND ON)
+ return()
+endif()
+
add_library(WrapDoubleConversion::WrapDoubleConversion INTERFACE IMPORTED)
find_package(double-conversion)
diff --git a/cmake/FindWrapRt.cmake b/cmake/FindWrapRt.cmake
index ef5475c53d..d14b922062 100644
--- a/cmake/FindWrapRt.cmake
+++ b/cmake/FindWrapRt.cmake
@@ -1,3 +1,10 @@
+# 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 WrapRt)
+ set(WrapRt_FOUND ON)
+ return()
+endif()
+
include(CheckCXXSourceCompiles)
include(CMakePushCheckState)