From ace549587073d387823815b02ec85a28da408844 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Wed, 5 Jun 2019 14:28:31 +0200 Subject: [PATCH] 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 --- cmake/FindAtomic.cmake | 7 +++++++ cmake/FindWrapDoubleConversion.cmake | 7 +++++++ cmake/FindWrapRt.cmake | 7 +++++++ 3 files changed, 21 insertions(+) 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 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)