aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitaly Novichkov <Wohlstand@users.noreply.github.com>2018-07-30 12:06:01 +0300
committerGitHub <noreply@github.com>2018-07-30 12:06:01 +0300
commitb3437fa6a76d946ba6e0c20574fbe4a0b751aab8 (patch)
tree71571bb7bd236b38551a48231362d60a007d564f
parentb5a38c540d5a2b5b6750a49eb25ca3c7388b099c (diff)
parent7a432775f1bcf680c1c77e101ddbc405fb6a70da (diff)
downloadlibADLMIDI-b3437fa6a76d946ba6e0c20574fbe4a0b751aab8.tar.gz
libADLMIDI-b3437fa6a76d946ba6e0c20574fbe4a0b751aab8.tar.bz2
libADLMIDI-b3437fa6a76d946ba6e0c20574fbe4a0b751aab8.zip
Merge pull request #146 from jpcima/visibility-hidden
hide private symbols
-rw-r--r--CMakeLists.txt11
-rw-r--r--src/adlmidi_private.hpp2
2 files changed, 12 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ab3e7e5..8d1fad6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -65,6 +65,15 @@ function(set_legacy_standard destTarget)
endif()
endif()
endfunction()
+
+function(set_visibility_hidden destTarget)
+ if(CMAKE_C_COMPILER_ID MATCHES "^(GNU|Clang)$")
+ target_compile_options(${destTarget} PRIVATE
+ -fvisibility=hidden -fvisibility-inlines-hidden)
+ target_compile_definitions(${destTarget} PRIVATE
+ "LIBADLMIDI_VISIBILITY")
+ endif()
+endfunction()
#===========================================================================================
option(libADLMIDI_STATIC "Build static library of libADLMIDI" ON)
@@ -273,6 +282,7 @@ if(libADLMIDI_STATIC)
set_target_properties(ADLMIDI_static PROPERTIES OUTPUT_NAME ADLMIDI)
target_include_directories(ADLMIDI_static PUBLIC ${libADLMIDI_SOURCE_DIR}/include)
set_legacy_standard(ADLMIDI_static)
+ set_visibility_hidden(ADLMIDI_static)
list(APPEND libADLMIDI_INSTALLS ADLMIDI_static)
if(WITH_EMBEDDED_BANKS AND WITH_GENADLDATA)
add_dependencies(ADLMIDI_static gen-adldata-run)
@@ -284,6 +294,7 @@ if(libADLMIDI_SHARED)
set_target_properties(ADLMIDI_shared PROPERTIES OUTPUT_NAME ADLMIDI)
target_include_directories(ADLMIDI_shared PUBLIC ${libADLMIDI_SOURCE_DIR}/include)
set_legacy_standard(ADLMIDI_shared)
+ set_visibility_hidden(ADLMIDI_shared)
list(APPEND libADLMIDI_INSTALLS ADLMIDI_shared)
if(WITH_EMBEDDED_BANKS AND WITH_GENADLDATA)
add_dependencies(ADLMIDI_shared gen-adldata-run)
diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp
index 4fb3e7f..10df24d 100644
--- a/src/adlmidi_private.hpp
+++ b/src/adlmidi_private.hpp
@@ -28,7 +28,7 @@
#ifndef ADLMIDI_EXPORT
# if defined (_WIN32) && defined(ADLMIDI_BUILD_DLL)
# define ADLMIDI_EXPORT __declspec(dllexport)
-# elif defined (LIBADLMIDI_VISIBILITY)
+# elif defined (LIBADLMIDI_VISIBILITY) && defined (__GNUC__)
# define ADLMIDI_EXPORT __attribute__((visibility ("default")))
# else
# define ADLMIDI_EXPORT