From 7c5a7bd73b33899f85b88a9c6460933dd35f39b8 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Thu, 8 Apr 2021 19:55:06 +1000 Subject: [PATCH] Make Findre2.cmake idempotent. (#25821) As per https://github.com/grpc/grpc/issues/25434, idempotence is necessary because CMake fails when another target with the same name already exists. Fixes #25434. --- cmake/modules/Findre2.cmake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmake/modules/Findre2.cmake b/cmake/modules/Findre2.cmake index 41df4547138..e4f8e4d706b 100644 --- a/cmake/modules/Findre2.cmake +++ b/cmake/modules/Findre2.cmake @@ -18,6 +18,13 @@ if(re2_FOUND) return() endif() +# As per https://github.com/grpc/grpc/issues/25434, idempotence is necessary +# because CMake fails when another target with the same name already exists. +if(TARGET re2::re2) + message(STATUS "Found RE2 via pkg-config already?") + return() +endif() + find_package(PkgConfig REQUIRED) # TODO(junyer): Use the IMPORTED_TARGET option whenever CMake 3.6 (or newer) # becomes the minimum required: that will take care of the add_library() and