From c4a2fed1123e56195cfd755981c56004da618935 Mon Sep 17 00:00:00 2001 From: Matias Fontanini Date: Tue, 29 Dec 2015 07:43:46 -0800 Subject: [PATCH] Don't define TINS_STATIC in config.h --- CMakeLists.txt | 2 +- include/tins/config.h.in | 3 --- include/tins/macros.h | 26 ++++++++++++-------------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b21c902..eaf72ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,7 +32,7 @@ IF(LIBTINS_BUILD_SHARED) ELSE(LIBTINS_BUILD_SHARED) MESSAGE(STATUS "Build will generate a static library.") SET(LIBTINS_TYPE STATIC) - SET(TINS_STATIC_BUILD ON) + ADD_DEFINITIONS("-DTINS_STATIC=1") ENDIF(LIBTINS_BUILD_SHARED) # The version number. diff --git a/include/tins/config.h.in b/include/tins/config.h.in index 6a2b0ee..88bc5f2 100644 --- a/include/tins/config.h.in +++ b/include/tins/config.h.in @@ -13,7 +13,4 @@ /* Use pcap_sendpacket to send l2 packets */ #cmakedefine HAVE_PACKET_SENDER_PCAP_SENDPACKET -/* Indicate whether libtins was built statically */ -#cmakedefine TINS_STATIC_BUILD - #endif // TINS_CONFIG_H diff --git a/include/tins/macros.h b/include/tins/macros.h index d35d3f1..670ae34 100644 --- a/include/tins/macros.h +++ b/include/tins/macros.h @@ -46,18 +46,6 @@ #define TINS_NOEXCEPT #define TINS_LIKELY(x) (x) #define TINS_UNLIKELY(x) (x) - // If libtins was built into a shared library - #if !defined(TINS_STATIC_BUILD) - // Export/import symbols, depending on whether we're compiling or consuming the lib - #ifdef tins_EXPORTS - #define TINS_API __declspec(dllexport) - #else - #define TINS_API __declspec(dllimport) - #endif // tins_EXPORTS - #else // TINS_STATIC_BUILD - // Otherwise, default this to an empty macro - #define TINS_API - #endif // TINS_STATIC_BUILD #else // Not Vistual Studio. Assume this is gcc compatible #define TINS_BEGIN_PACK @@ -67,9 +55,19 @@ #define TINS_NOEXCEPT noexcept #define TINS_LIKELY(x) __builtin_expect((x),1) #define TINS_UNLIKELY(x) __builtin_expect((x),0) - #define TINS_API #endif // _MSC_VER - +// If libtins was built into a shared library +#if defined(_WIN32) && !defined(TINS_STATIC) + // Export/import symbols, depending on whether we're compiling or consuming the lib + #ifdef tins_EXPORTS + #define TINS_API __declspec(dllexport) + #else + #define TINS_API __declspec(dllimport) + #endif // tins_EXPORTS +#else + // Otherwise, default this to an empty macro + #define TINS_API +#endif // _WIN32 && !TINS_STATIC #endif // TINS_MACROS_H