Skip to content

Commit

Permalink
Updated static lib process
Browse files Browse the repository at this point in the history
  • Loading branch information
fpoussin committed Mar 16, 2020
1 parent dcd481f commit 4789832
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 18 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 17 additions & 8 deletions build_msvc.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,51 @@ 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
)

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%

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
12 changes: 6 additions & 6 deletions src/usb/usb.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 4789832

Please sign in to comment.