]> Devoid-pointer.net GitWeb - libHPCS.git/commitdiff
Export library functions only when the library is the build target
authorMichal Malý <madcatxster@devoid-pointer.net>
Fri, 12 May 2017 08:22:47 +0000 (10:22 +0200)
committerMichal Malý <madcatxster@devoid-pointer.net>
Fri, 12 May 2017 08:22:47 +0000 (10:22 +0200)
CMakeLists.txt
include/libHPCS.h

index 0a7cffd9635c1a65cab70d43065068a3de580c02..33d66dd0c54692ed9fa5a3e78a5b28dfa33a0a5e 100644 (file)
@@ -13,6 +13,7 @@ if (NOT MSVC)
     endif()
 endif()
 
+add_definitions(-D_HPCS_BUILD_DLL)
 
 if (WIN32)
     set(WIN32_EXTRA_LIBS Shlwapi)
index ab51fe94611de7e2bd201fdc4064f05cf1a52898..e31535137411454e5df2b146780ba53d2771ce17 100644 (file)
@@ -9,12 +9,20 @@ extern "C" {
 #include <stdint.h>
 
 #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,