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
15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ function(generate_config_file)
set(ENABLE_DEBUG_LOGGING ${LIBUSB_ENABLE_DEBUG_LOGGING})
endif()

if(WIN32 AND LIBUSB_ENABLE_WINDOWS_HOTPLUG)
set(LIBUSB_WINDOWS_HOTPLUG 1)
endif()

if(CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "GNU")
check_c_compiler_flag("-fvisibility=hidden" HAVE_VISIBILITY)
endif()
Expand Down Expand Up @@ -104,6 +108,10 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux")
option(LIBUSB_ENABLE_UDEV "Enable udev backend for device enumeration" ON)
endif()

if(WIN32)
option(LIBUSB_ENABLE_WINDOWS_HOTPLUG "Enable Windows hotplug support" OFF)
endif()

set(LIBUSB_GEN_INCLUDES "${CMAKE_CURRENT_BINARY_DIR}/gen_include")
generate_config_file()

Expand Down Expand Up @@ -160,6 +168,13 @@ if(WIN32)
)
target_compile_definitions(usb-1.0 PRIVATE $<$<C_COMPILER_ID:MSVC>:_CRT_SECURE_NO_WARNINGS=1>)
target_link_libraries(usb-1.0 PRIVATE windowsapp)
if(LIBUSB_ENABLE_WINDOWS_HOTPLUG)
target_sources(usb-1.0 PRIVATE
"${LIBUSB_ROOT}/os/windows_hotplug.c"
"${LIBUSB_ROOT}/os/windows_hotplug.h"
)
target_compile_definitions(usb-1.0 PRIVATE LIBUSB_WINDOWS_HOTPLUG=1)
endif()
set_target_properties(usb-1.0 PROPERTIES UNITY_BUILD OFF)
else()
# common POSIX/non-Windows sources
Expand Down
3 changes: 3 additions & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
/* #define to 1 if compiling for a Windows platform. */
#cmakedefine PLATFORM_WINDOWS 1

/* #define to 1 to enable Windows hotplug support. */
#cmakedefine LIBUSB_WINDOWS_HOTPLUG 1


#if defined(__GNUC__)
#define PRINTF_FORMAT(a, b) __attribute__ ((format (__printf__, a, b)))
Expand Down
Loading