From 9ad2f08a2d9db5167023536b79cee5409b141419 Mon Sep 17 00:00:00 2001 From: Max Golovanov Date: Tue, 18 May 2021 22:27:49 -0700 Subject: [PATCH] Fix an issue with GMOCK_LIB NOTFOUND with msvc --- exporters/otlp/CMakeLists.txt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/exporters/otlp/CMakeLists.txt b/exporters/otlp/CMakeLists.txt index 1bc3a78939..1f3dec6dd0 100644 --- a/exporters/otlp/CMakeLists.txt +++ b/exporters/otlp/CMakeLists.txt @@ -37,12 +37,13 @@ if(BUILD_TESTING) TEST_LIST recordable_test) 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) + else() + 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() endif() if(MSVC AND CMAKE_BUILD_TYPE STREQUAL "Debug") find_library(GMOCK_LIB gmockd PATH_SUFFIXES lib)