From f48969e8113c890fb1a38c7d8d675919f8d6ba24 Mon Sep 17 00:00:00 2001 From: Tom Tan Date: Tue, 4 May 2021 23:14:34 -0700 Subject: [PATCH] Unset GMOCK_LIB before find_library to force lookup --- exporters/otlp/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/exporters/otlp/CMakeLists.txt b/exporters/otlp/CMakeLists.txt index 526a824da6..abdd9a964b 100644 --- a/exporters/otlp/CMakeLists.txt +++ b/exporters/otlp/CMakeLists.txt @@ -37,6 +37,12 @@ if(BUILD_TESTING) if(MSVC) add_definitions(-DGTEST_LINKED_AS_SHARED_LIBRARY=1) endif() + if(GMOCK_LIB) + # unset GMOCK_LIB to force find_library to redo the lookup, as the cached + # entry could cause linking to incorrect flavor of gmock and leading to + # runtime error. + unset(GMOCK_LIB CACHE) + endif() if(MSVC AND CMAKE_BUILD_TYPE STREQUAL "Debug") find_library(GMOCK_LIB gmockd PATH_SUFFIXES lib) else()