Skip to content

Commit 53c06f6

Browse files
authored
Fix Windows 7 incompatibility caused by linking windowsapp (#43)
windowsapp introduces API-set imports that don't resolve on Windows 7, so the DLL fails to load there. It is only required for UWP/Store builds, so link it only when targeting WindowsStore and link kernel32/user32 for classic desktop builds. Fixes: #41
1 parent 914a504 commit 53c06f6

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

CMakeLists.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ if(EMSCRIPTEN)
2222
enable_language(CXX)
2323
endif()
2424

25-
message("Building usb-1.0 for: ${CMAKE_SYSTEM_NAME}")
25+
message(STATUS "Building usb-1.0 for: ${CMAKE_SYSTEM_NAME}")
2626

2727
# This function generates all the local variables what end up getting written to config.
2828
# We use a function as any vars set in this context don't mess with the rest of the file.
@@ -192,7 +192,15 @@ if(WIN32)
192192
$<$<C_COMPILER_ID:MSVC>:${LIBUSB_ROOT}/libusb-1.0.rc>
193193
)
194194
target_compile_definitions(usb-1.0 PRIVATE $<$<C_COMPILER_ID:MSVC>:_CRT_SECURE_NO_WARNINGS=1>)
195-
target_link_libraries(usb-1.0 PRIVATE windowsapp)
195+
196+
if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
197+
# UWP/Store builds require the WindowsApp umbrella library
198+
target_link_libraries(usb-1.0 PRIVATE windowsapp)
199+
else()
200+
# windowsapp pulls in API-set imports unavailable on Windows 7
201+
target_link_libraries(usb-1.0 PRIVATE kernel32 user32)
202+
endif()
203+
196204
if(LIBUSB_ENABLE_WINDOWS_HOTPLUG)
197205
target_sources(usb-1.0 PRIVATE
198206
"${LIBUSB_ROOT}/os/windows_hotplug.c"

0 commit comments

Comments
 (0)