From 4b80c5bf69999a438a485ccfca55e1d05b090501 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Mal=C3=BD?= Date: Fri, 12 May 2017 10:22:47 +0200 Subject: [PATCH] Export library functions only when the library is the build target --- CMakeLists.txt | 1 + include/libHPCS.h | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a7cffd..33d66dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,7 @@ if (NOT MSVC) endif() endif() +add_definitions(-D_HPCS_BUILD_DLL) if (WIN32) set(WIN32_EXTRA_LIBS Shlwapi) diff --git a/include/libHPCS.h b/include/libHPCS.h index ab51fe9..e315351 100644 --- a/include/libHPCS.h +++ b/include/libHPCS.h @@ -9,12 +9,20 @@ extern "C" { #include #ifdef _WIN32 -#define LIBHPCS_API __declspec(dllexport) + #ifdef _HPCS_BUILD_DLL + #define LIBHPCS_API __declspec(dllexport) + #else + #define LIBHPCS_API __declspec(dllimport) + #endif /* _HPCS_BUILD_DLL */ #define LIBHPCS_CC __cdecl #else -#define LIBHPCS_API __attribute__ ((visibility ("default"))) -#define LIBHPCS_CC -#endif + #ifdef _HPCS_BUILD_DLL + #define LIBHPCS_API __attribute__ ((visibility ("default"))) + #else + #define LIBHPCS_API + #endif /* _HPCS_BUILD_DLL */ + #define LIBHPCS_CC +#endif /* _WIN32 */ enum HPCS_FileType { HPCS_TYPE_CE_ANALOG, -- 2.43.5