Skip to content

Commit acba6b2

Browse files
authored
Merge branch 'main' into fix-visibility
2 parents 4ca012d + 2eb3a90 commit acba6b2

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ function(generate_config_file)
7474
set(ENABLE_DEBUG_LOGGING ${LIBUSB_ENABLE_DEBUG_LOGGING})
7575
endif()
7676

77+
if(WIN32 AND LIBUSB_ENABLE_WINDOWS_HOTPLUG)
78+
set(LIBUSB_WINDOWS_HOTPLUG 1)
79+
endif()
80+
7781
file(MAKE_DIRECTORY "${LIBUSB_GEN_INCLUDES}")
7882
if(NOT MSVC)
7983
set(_GNU_SOURCE TRUE)
@@ -104,6 +108,10 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux")
104108
option(LIBUSB_ENABLE_UDEV "Enable udev backend for device enumeration" ON)
105109
endif()
106110

111+
if(WIN32)
112+
option(LIBUSB_ENABLE_WINDOWS_HOTPLUG "Enable Windows hotplug support" OFF)
113+
endif()
114+
107115
set(LIBUSB_GEN_INCLUDES "${CMAKE_CURRENT_BINARY_DIR}/gen_include")
108116
generate_config_file()
109117

@@ -160,6 +168,13 @@ if(WIN32)
160168
)
161169
target_compile_definitions(usb-1.0 PRIVATE $<$<C_COMPILER_ID:MSVC>:_CRT_SECURE_NO_WARNINGS=1>)
162170
target_link_libraries(usb-1.0 PRIVATE windowsapp)
171+
if(LIBUSB_ENABLE_WINDOWS_HOTPLUG)
172+
target_sources(usb-1.0 PRIVATE
173+
"${LIBUSB_ROOT}/os/windows_hotplug.c"
174+
"${LIBUSB_ROOT}/os/windows_hotplug.h"
175+
)
176+
target_compile_definitions(usb-1.0 PRIVATE LIBUSB_WINDOWS_HOTPLUG=1)
177+
endif()
163178
set_target_properties(usb-1.0 PROPERTIES UNITY_BUILD OFF)
164179
else()
165180
# common POSIX/non-Windows sources

config.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@
5252
/* #define to 1 if compiling for a Windows platform. */
5353
#cmakedefine PLATFORM_WINDOWS 1
5454

55+
/* #define to 1 to enable Windows hotplug support. */
56+
#cmakedefine LIBUSB_WINDOWS_HOTPLUG 1
57+
5558

5659
#if defined(__GNUC__)
5760
#define PRINTF_FORMAT(a, b) __attribute__ ((format (__printf__, a, b)))

0 commit comments

Comments
 (0)