Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions windows/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ target_link_libraries(hidapi_winapi
PUBLIC hidapi_include
)

target_compile_definitions(hidapi_winapi
# CMake compiles hidapi_descriptor_reconstruct.c as a separate translation unit,
# so hid.c must not #include it (to avoid duplicate symbol LNK4006 in static builds).
PRIVATE HIDAPI_CMAKE_V0_BUILD
)

if(NOT BUILD_SHARED_LIBS)
target_compile_definitions(hidapi_winapi
# prevent marking functions as __declspec(dllexport) for static library build
Expand Down
4 changes: 3 additions & 1 deletion windows/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,9 @@ HID_API_EXPORT const wchar_t * HID_API_CALL hid_error(hid_device *dev)
return last_global_error_str;
}

#ifndef hidapi_winapi_EXPORTS
#ifndef HIDAPI_CMAKE_V0_BUILD
/* Include the descriptor reconstruction code when NOT building with CMake.
CMake builds compile hidapi_descriptor_reconstruct.c as a separate translation unit. */
#include "hidapi_descriptor_reconstruct.c"
#endif

Expand Down
Loading