windows: don't mark with dllexport in static build (#507)

Don't mark API functions with __declspec(dllexport) when building a static library on Windows.
Enforced by CMake builds.
For other builds a compile definition is available.

Related: #480
This commit is contained in:
Ihor Dutchak
2023-02-22 02:05:47 +02:00
committed by GitHub
parent eecbe74bb1
commit 438d06568d
2 changed files with 14 additions and 1 deletions
+6 -1
View File
@@ -7,7 +7,7 @@
libusb/hidapi Team
Copyright 2022, All Rights Reserved.
Copyright 2023, All Rights Reserved.
At the discretion of the user of this library,
this software may be licensed under the terms of the
@@ -30,10 +30,15 @@
#include <wchar.h>
#ifdef _WIN32
/* #480: this is to be refactored properly for v1.0 */
#ifndef HID_API_EXPORT
#define HID_API_EXPORT __declspec(dllexport)
#endif
#define HID_API_CALL
#else
#ifndef HID_API_EXPORT
#define HID_API_EXPORT /**< API export macro */
#endif
#define HID_API_CALL /**< API call macro */
#endif
+8
View File
@@ -20,6 +20,14 @@ target_link_libraries(hidapi_winapi
PUBLIC hidapi_include
)
if(NOT BUILD_SHARED_LIBS)
target_compile_definitions(hidapi_winapi
# prevent marking functions as __declspec(dllexport) for static library build
# #480: this should be refactored for v1.0
PUBLIC HID_API_EXPORT
)
endif()
set_target_properties(hidapi_winapi
PROPERTIES
EXPORT_NAME "winapi"