From ca8145904b5958d794bf5f30b5eccde08eb271e7 Mon Sep 17 00:00:00 2001 From: milek7 Date: Sat, 30 Jan 2021 16:00:58 +0100 Subject: [PATCH] do not make unnecessary exports on nix platforms --- CMakeLists.txt | 7 +++++++ lua.cpp | 12 +++++++++--- network/backend/asio.h | 1 + 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c39f90e1..6bfa6094 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,8 @@ if(POLICY CMP0069) cmake_policy(SET CMP0069 NEW) endif() +include(CheckCXXSymbolExists) + set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMake_modules/") @@ -329,6 +331,11 @@ set_target_properties( ${PROJECT_NAME} DEBUG_POSTFIX "_d" ) +check_cxx_symbol_exists(__GNUC__ "" COMPILER_HAVE_GNUC) +if (COMPILER_HAVE_GNUC) + set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-fvisibility=hidden") +endif() + if(NOT ${CMAKE_VERSION} VERSION_LESS "3.16.0") option(USE_PCH "Use precompiled header" ON) diff --git a/lua.cpp b/lua.cpp index 12b3a01f..ede8e197 100644 --- a/lua.cpp +++ b/lua.cpp @@ -62,10 +62,16 @@ int lua::openffi(lua_State *s) return 1; } -#ifdef _WIN32 -#define EXPORT __declspec(dllexport) +#if defined _WIN32 +# if defined __GNUC__ +# define EXPORT __attribute__ ((dllexport)) +# else +# define EXPORT __declspec(dllexport) +# endif +#elif defined __GNUC__ +# define EXPORT __attribute__ ((visibility ("default"))) #else -#define EXPORT +# define EXPORT #endif extern "C" diff --git a/network/backend/asio.h b/network/backend/asio.h index 77111892..47e731c7 100644 --- a/network/backend/asio.h +++ b/network/backend/asio.h @@ -2,6 +2,7 @@ #undef new #endif +#define ASIO_DISABLE_VISIBILITY #include #include "network/network.h"