Skip to content
Open
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
16 changes: 14 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if(EMSCRIPTEN)
enable_language(CXX)
endif()

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

# This function generates all the local variables what end up getting written to config.
# We use a function as any vars set in this context don't mess with the rest of the file.
Expand Down Expand Up @@ -192,7 +192,19 @@ if(WIN32)
$<$<C_COMPILER_ID:MSVC>:${LIBUSB_ROOT}/libusb-1.0.rc>
)
target_compile_definitions(usb-1.0 PRIVATE $<$<C_COMPILER_ID:MSVC>:_CRT_SECURE_NO_WARNINGS=1>)
target_link_libraries(usb-1.0 PRIVATE windowsapp)

include(CheckCSourceCompiles)
set(CMAKE_REQUIRED_LIBRARIES windowsapp)
check_c_source_compiles("int main(void) { return 0; }" HAVE_WINDOWSAPP_LIB)
unset(CMAKE_REQUIRED_LIBRARIES)

if(HAVE_WINDOWSAPP_LIB)
target_link_libraries(usb-1.0 PRIVATE windowsapp)
else()
message(WARNING "You're targeting old no longer supported version of Windows SDK, consider building against a newer SDK to get better support for Windows 10/11 and avoid vulnerabilities in older SDKs")
target_link_libraries(usb-1.0 PRIVATE kernel32 user32)
endif()

if(LIBUSB_ENABLE_WINDOWS_HOTPLUG)
target_sources(usb-1.0 PRIVATE
"${LIBUSB_ROOT}/os/windows_hotplug.c"
Expand Down
Loading