diff --git a/CMakeLists.txt b/CMakeLists.txt index 9294bc20d..e6784fc37 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -583,10 +583,10 @@ endif (HAVE_PTHREAD) if (gflags_FOUND) target_link_libraries (glog PUBLIC gflags) - if (NOT BUILD_SHARED_LIBS) - # Don't use __declspec(dllexport|dllimport) if this is a static build - targeT_compile_definitions (glog PUBLIC GFLAGS_DLL_DECLARE_FLAG= GFLAGS_DLL_DEFINE_FLAG=) - endif (NOT BUILD_SHARED_LIBS) + target_compile_definitions (glog PRIVATE + GFLAGS_DLL_DECLARE_FLAG=GOOGLE_GLOG_DLL_DECL + GFLAGS_DLL_DEFINE_FLAG=GOOGLE_GLOG_DLL_DECL + ) endif (gflags_FOUND) if (ANDROID) diff --git a/src/glog/logging.h.in b/src/glog/logging.h.in index ae682094a..1e80cceb3 100644 --- a/src/glog/logging.h.in +++ b/src/glog/logging.h.in @@ -86,6 +86,14 @@ #include // a third place for uint16_t or u_int16_t #endif +#ifdef GFLAGS_DLL_DECLARE_FLAG +#define GLOG_GFLAGS_DLL_DECLARE_FLAG_WAS_DEFINED +#pragma push_macro("GFLAGS_DLL_DECLARE_FLAG") +#undef GFLAGS_DLL_DECLARE_FLAG +#endif // defined(GFLAGS_DLL_DECLARE_FLAG) + +#define GFLAGS_DLL_DECLARE_FLAG GOOGLE_GLOG_DLL_DECL + #if @ac_cv_have_libgflags@ #include #endif @@ -1876,4 +1884,9 @@ GOOGLE_GLOG_DLL_DECL void InstallFailureWriter( @ac_google_end_namespace@ +#ifdef GLOG_GFLAGS_DLL_DECLARE_FLAG_WAS_DEFINED +#undef GLOG_GFLAGS_DLL_DECLARE_FLAG_WAS_DEFINED +#pragma pop_macro("GFLAGS_DLL_DECLARE_FLAG") +#endif // defined(GLOG_GFLAGS_DLL_DECLARE_FLAG_WAS_DEFINED) + #endif // _LOGGING_H_ diff --git a/src/logging_custom_prefix_unittest.cc b/src/logging_custom_prefix_unittest.cc index 9f9345d56..c9fb5b819 100644 --- a/src/logging_custom_prefix_unittest.cc +++ b/src/logging_custom_prefix_unittest.cc @@ -29,7 +29,6 @@ // // Author: Ray Sidney -#include "config_for_unittests.h" #include "utilities.h" #include