Skip to content

Instantly share code, notes, and snippets.

@t-mat
Last active March 9, 2024 03:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save t-mat/c0de3b35fb92675bffa7c6181c5b0fa8 to your computer and use it in GitHub Desktop.
Save t-mat/c0de3b35fb92675bffa7c6181c5b0fa8 to your computer and use it in GitHub Desktop.
Build JPEG XL with VC++2019
@rem Build JpegXL for Windows x64 Desktop, VC++2019
@setlocal enabledelayedexpansion
@echo off
pushd .
set /a errorno=1
set "TAG=v0.10.2"
git --version || echo "git" not found && goto :ERROR
rem
rem Set Visual C++ environment for Windows, desktop, x64.
rem
rem https://github.com/Microsoft/vswhere
rem https://github.com/microsoft/vswhere/wiki/Find-VC#batch
rem
set "vswhere=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
if not exist "%vswhere%" (
echo Can't find "vswhere.exe". Please install the latest version of Visual Studio.
goto :ERROR
)
set "InstallDir="
for /f "usebackq tokens=*" %%i in (`"%vswhere%" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do (
set "InstallDir=%%i"
)
if "%InstallDir%" == "" (
echo Can't find Visual C++. Please install the latest version of Visual C++.
goto :ERROR
)
rem Set -no_logo
rem For details, see %InstallDir%\Common7\Tools\vsdevcmd\core\parse_cmd.bat
set __VSCMD_ARG_NO_LOGO=1
rem Disable warning C4244, C4267 C4806, C4305
set "_CL_=/utf-8 /wd4244 /wd4267 /wd4305 /wd4806 /I%CD%/libjxl/lib/include"
echo call "%InstallDir%\VC\Auxiliary\Build\vcvars64.bat"
call "%InstallDir%\VC\Auxiliary\Build\vcvars64.bat" || goto :ERROR
msbuild -version || goto : ERROR
rem Clone repo
if not exist "libjxl" (
git clone -q --depth=1 --branch=%TAG% https://github.com/libjxl/libjxl.git || goto :ERROR
)
cd libjxl || goto :ERROR
if not exist "third_party\googletst\README.md" (
git submodule update --init --recursive || goto :ERROR
)
rem Build
if not exist build ( mkdir build )
cd build || goto :ERROR
cmake .. -A x64 -DBUILD_TESTING=OFF -DCXX_FUZZERS_SUPPORTED=OFF -DJPEGXL_ENABLE_DEVTOOLS=OFF -DJPEGXL_ENABLE_FUZZERS=OFF -DJPEGXL_ENABLE_TOOLS=OFF -DJPEGXL_STATIC=ON || goto :ERROR
msbuild LIBJXL.sln /nologo /v:minimal /m /p:Configuration=Release /p:Platform=x64 /t:Clean,Build || goto :ERROR
echo.
echo All .lib files are in %CD%\lib\Release\*.lib
echo.
echo Build Status - SUCCEEDED
set /a errorno=0
goto :END
:ERROR
echo Abort by error.
echo Build Status - ERROR
:END
popd
exit /B %errorno%
@t-mat
Copy link
Author

t-mat commented Mar 29, 2021

cd /d "%USERPROFILE%\Documents"
md my-jpeg-xl
cd my-jpeg-xl
curl -JOL https://gist.githubusercontent.com/t-mat/c0de3b35fb92675bffa7c6181c5b0fa8/raw/jpeg-xl-msvc-2019-x64-build.bat
type jpeg-xl-msvc-2019-x64-build.bat | find "" /V > build.bat
.\build.bat
dir libjxl\build\lib\Release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment