diff --git a/README.md b/README.md index 356c582..963733a 100755 --- a/README.md +++ b/README.md @@ -40,15 +40,16 @@ Alternatively build as static library (best for portability) ```shell mkdir build && cd build qmake CONFIG+=static_lib .. -# Link with '*.a' file later in you project +make install ``` -**MSVC 2017** +**MSVC** You need the Windows SDKs to compile libusb These are available from the Visual Studio Installer +The following script builds and installs a static library into your Qt version ``` -build_msvc2017.bat [x64|x86] QT_PATH -ie: build_msvc2017.bat x64 C:\Qt\5.14.1\msvc2017_64 +build_msvc.bat 2017|2019 x64|x86 dynamic|static QT_PATH +ie: build_msvc2017.bat 2017 x64 static C:\Qt\5.14.1\msvc2017_64 ``` ## Using the library or code directly diff --git a/build_msvc.bat b/build_msvc.bat index 43b21d5..4a9aba7 100644 --- a/build_msvc.bat +++ b/build_msvc.bat @@ -14,6 +14,12 @@ IF "%2"=="" ( ) IF "%3"=="" ( + echo "Missing lib type [dynamic|static]" + pause + exit /b 1c +) + +IF "%4"=="" ( echo "Missing QT path ie: C:\Qt\5.14.1\msvc2017" pause exit /b 1c @@ -21,18 +27,20 @@ IF "%3"=="" ( SET MSVC=%1 SET ARCH=%2 -SET QTDIR=%3 +SET LIBTYPE=%3 +SET QTDIR=%4 SET BUILDTOOL=jom SET vcarch=%ARCH% SET usbarch=%ARCH% IF "%ARCH%" == "x64" SET vcarch=amd64 IF "%ARCH%" == "x86" SET usbarch=Win32 -IF "%MSVC%" == "2017" SET MSVC_VER=v141 -IF "%MSVC%" == "2019" SET MSVC_VER=v142 SET PROJDIR=%CD% SET BUILDDIR=%PROJDIR%\..\build-qtusb-%ARCH% +SET STATIC="" +IF "%LIBTYPE%" == "static" SET STATIC="CONFIG+=static_lib" + CALL "C:\Program Files (x86)\Microsoft Visual Studio\%MSVC%\Community\VC\Auxiliary\Build\vcvarsall.bat" %vcarch% SET PATH=%QTDIR%\bin;C:\Qt\Tools\QtCreator\bin;%PATH% @@ -40,16 +48,17 @@ SET PATH=%QTDIR%\bin;C:\Qt\Tools\QtCreator\bin;%PATH% WHERE /Q jom IF %errorlevel% NEQ 0 set BUILDTOOL=nmake -git submodule update --init --recursive. +git submodule update --init --recursive echo %BUILDDIR% RMDIR /S /Q %BUILDDIR% MKDIR %BUILDDIR% CD %BUILDDIR% -%QTDIR%\bin\qmake.exe CONFIG+=static_lib %PROJDIR% -%BUILDTOOL% sub-tests -CD tests\auto -nmake check +%QTDIR%\bin\qmake.exe %STATIC% %PROJDIR% +%BUILDTOOL% +%BUILDTOOL% uninstall +%BUILDTOOL% install +%BUILDTOOL% docs install_docs endlocal diff --git a/src/usb/usb.pro b/src/usb/usb.pro index 5c432ea..d0e2414 100755 --- a/src/usb/usb.pro +++ b/src/usb/usb.pro @@ -8,11 +8,11 @@ DEFINES += QT_BUILD_USB_LIB include($$PWD/usb-lib.pri) CONFIG(static_lib) { - message("Build as static library") - TEMPLATE = lib - CONFIG += staticlib + message("Build as Qt module (static library)") + CONFIG += staticlib } else { - message("Build as Qt module (dynamic library)") - load(qt_build_config) - load(qt_module) + message("Build as Qt module (dynamic library)") } + +load(qt_build_config) +load(qt_module)