MSYS2 / MinGW support (#61)
diff --git a/README.md b/README.md
index 569e8b2..f3d0ab5 100644
--- a/README.md
+++ b/README.md
@@ -29,6 +29,20 @@
cmake -G "NMake Makefiles" ..
nmake
```
+
+Windows with MinGW in MSYS2:
+
+No need to download libusb separately or set LIBUSB_ROOT.
+
+```console
+pacman -S $MINGW_PACKAGE_PREFIX-{toolchain,cmake,libusb}
+mkdir build
+cd build
+MSYS2_ARG_CONV_EXCL=- cmake .. -G"MSYS Makefiles" -DCMAKE_INSTALL_PREFIX=$MINGW_PREFIX
+make
+make install DESTDIR=/ # optional
+```
+
## Overview
`picotool` is a tool for inspecting RP2040 binaries, and interacting with RP2040 devices when they are in BOOTSEL mode. (As of version 1.1 of `picotool` it is also possible to interact with RP2040 devices that are not in BOOTSEL mode, but are using USB stdio support from the Raspberry Pi Pico SDK by using the `-f` argument of `picotool`).
diff --git a/cmake/FindLIBUSB.cmake b/cmake/FindLIBUSB.cmake
index 26e924c..169f594 100644
--- a/cmake/FindLIBUSB.cmake
+++ b/cmake/FindLIBUSB.cmake
@@ -12,12 +12,12 @@
# in cache already
set(LIBUSB_FOUND TRUE)
else (LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)
- IF (NOT WIN32)
+ IF (NOT MSVC)
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
find_package(PkgConfig)
pkg_check_modules(PC_LIBUSB libusb-1.0)
- ENDIF(NOT WIN32)
+ ENDIF ()
FIND_PATH(LIBUSB_INCLUDE_DIR libusb.h
HINTS $ENV{LIBUSB_ROOT}/include/libusb-1.0
PATHS ${PC_LIBUSB_INCLUDEDIR} ${PC_LIBUSB_INCLUDE_DIRS})
diff --git a/main.cpp b/main.cpp
index b4e33e3..31d0c8c 100644
--- a/main.cpp
+++ b/main.cpp
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#ifdef _MSC_VER
+#ifdef _WIN32
#define _CRT_SECURE_NO_WARNINGS
#endif
@@ -37,7 +37,7 @@
#endif
// tsk namespace is polluted on windows
-#ifdef _MSC_VER
+#ifdef _WIN32
#undef min
#undef max
@@ -2043,7 +2043,7 @@
libusb_device_handle *dev_handle;
ret = libusb_open(device, &dev_handle);
if (ret) {
-#if _MSC_VER
+#if _WIN32
fail(ERROR_USB, "Unable to access device to reboot it; Make sure there is a driver installed via Zadig\n", ret);
#else
fail(ERROR_USB, "Unable to access device to reboot it; Use sudo or setup a udev rule\n", ret);