Commit cf517375 authored by Billy Donahue's avatar Billy Donahue
Browse files

Merge pull request #605 from d-meiser/fix-visibility-hidden

Fix building of gtest with -fvisibility=hidden [#451]
parents 43359642 84d7ff10
...@@ -22,6 +22,11 @@ option(gtest_build_samples "Build gtest's sample programs." OFF) ...@@ -22,6 +22,11 @@ option(gtest_build_samples "Build gtest's sample programs." OFF)
option(gtest_disable_pthreads "Disable uses of pthreads in gtest." OFF) option(gtest_disable_pthreads "Disable uses of pthreads in gtest." OFF)
option(
gtest_hide_internal_symbols
"Build gtest with internal symbols hidden in shared libraries."
OFF)
# Defines pre_project_set_up_hermetic_build() and set_up_hermetic_build(). # Defines pre_project_set_up_hermetic_build() and set_up_hermetic_build().
include(cmake/hermetic_build.cmake OPTIONAL) include(cmake/hermetic_build.cmake OPTIONAL)
...@@ -46,6 +51,11 @@ if (COMMAND set_up_hermetic_build) ...@@ -46,6 +51,11 @@ if (COMMAND set_up_hermetic_build)
set_up_hermetic_build() set_up_hermetic_build()
endif() endif()
if (gtest_hide_internal_symbols)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
endif()
# Define helper functions and macros used by Google Test. # Define helper functions and macros used by Google Test.
include(cmake/internal_utils.cmake) include(cmake/internal_utils.cmake)
......
...@@ -920,14 +920,14 @@ using ::std::tuple_size; ...@@ -920,14 +920,14 @@ using ::std::tuple_size;
#endif // GTEST_HAS_SEH #endif // GTEST_HAS_SEH
#ifdef _MSC_VER #ifdef _MSC_VER
# if GTEST_LINKED_AS_SHARED_LIBRARY # if GTEST_LINKED_AS_SHARED_LIBRARY
# define GTEST_API_ __declspec(dllimport) # define GTEST_API_ __declspec(dllimport)
# elif GTEST_CREATE_SHARED_LIBRARY # elif GTEST_CREATE_SHARED_LIBRARY
# define GTEST_API_ __declspec(dllexport) # define GTEST_API_ __declspec(dllexport)
# endif # endif
#elif __GNUC__ >= 4 || defined(__clang__)
#endif // _MSC_VER # define GTEST_API_ __attribute__((visibility ("default")))
#endif // _MSC_VER
#ifndef GTEST_API_ #ifndef GTEST_API_
# define GTEST_API_ # define GTEST_API_
......
...@@ -1032,7 +1032,7 @@ class TestResultAccessor { ...@@ -1032,7 +1032,7 @@ class TestResultAccessor {
#if GTEST_CAN_STREAM_RESULTS_ #if GTEST_CAN_STREAM_RESULTS_
// Streams test results to the given port on the given host machine. // Streams test results to the given port on the given host machine.
class StreamingListener : public EmptyTestEventListener { class GTEST_API_ StreamingListener : public EmptyTestEventListener {
public: public:
// Abstract base class for writing strings to a socket. // Abstract base class for writing strings to a socket.
class AbstractSocketWriter { class AbstractSocketWriter {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment