From d06518785a2e1c67c29e86ad718fff0ca061df8f Mon Sep 17 00:00:00 2001
From: TimePath <andrew.hardaker1995@gmail.com>
Date: Sun, 30 Jul 2017 11:30:28 +1000
Subject: [PATCH] Default symbol visibility to hidden

---
 CMakeLists.txt         | 20 ++++++++++++++------
 include/modulesystem.h | 11 +++--------
 2 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 58715216..065ddf10 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -57,8 +57,16 @@ endif ()
 # Flags
 #-----------------------------------------------------------------------
 
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}   -fno-strict-aliasing")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing -fno-exceptions -fno-rtti")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti")
+macro(addflags args)
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${args}")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${args}")
+endmacro()
+addflags("-fno-strict-aliasing")
+if (NOT WIN32)
+    addflags("-fvisibility=hidden")
+endif ()
+
 set(CMAKE_POSITION_INDEPENDENT_CODE 1)
 set(GTK_NS "GTK2" CACHE STRING "GTK variable prefix")
 
@@ -106,10 +114,10 @@ include_directories("${PROJECT_SOURCE_DIR}/libs")
 macro(copy_dlls target)
     if (WIN32)
         add_custom_command(TARGET ${target} POST_BUILD
-            COMMAND bash
-            ARGS -c "ldd '$<TARGET_FILE:${target}>' | grep -v /c/Windows | awk '{ print $1 }' | while read dll; do cp \"$(which $dll)\" '${PROJECT_BINARY_DIR}'; done"
-            VERBATIM
-        )
+                COMMAND bash
+                ARGS -c "ldd '$<TARGET_FILE:${target}>' | grep -v /c/Windows | awk '{ print $1 }' | while read dll; do cp \"$(which $dll)\" '${PROJECT_BINARY_DIR}'; done"
+                VERBATIM
+                )
     endif ()
 endmacro()
 
diff --git a/include/modulesystem.h b/include/modulesystem.h
index 8b1913fb..b8c83489 100644
--- a/include/modulesystem.h
+++ b/include/modulesystem.h
@@ -26,15 +26,10 @@
 #include "debugging/debugging.h"
 
 #if defined( WIN32 )
-#ifdef MINGW32
-#define RADIANT_DLLEXPORT __declspec( dllexport )
-#define RADIANT_DLLIMPORT __declspec( dllimport )
+#define RADIANT_DLLEXPORT __declspec(dllexport)
+#define RADIANT_DLLIMPORT __declspec(dllimport)
 #else
-#define RADIANT_DLLEXPORT __stdcall
-#define RADIANT_DLLIMPORT __stdcall
-#endif
-#else
-#define RADIANT_DLLEXPORT
+#define RADIANT_DLLEXPORT __attribute__((visibility("default")))
 #define RADIANT_DLLIMPORT
 #endif
 
-- 
2.39.5