@echo off REM Builds hiredis (static, no SSL) in 4 variants (Win32/x64 x Release/Debug) with the VS2017 (v141) toolset. REM Run it from the unpacked hiredis source directory (see source.url), the results are copied next to this script set VSDIR=C:\Program Files\Microsoft Visual Studio\18\Community set VCVARSALL=%VSDIR%\VC\Auxiliary\Build\vcvarsall.bat set CMAKE=%VSDIR%\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe REM CMakeLists.txt forces /Z7 even for Release, replace it with a harmless flag (Debug gets /Z7 below) powershell -NoProfile -Command "(Get-Content CMakeLists.txt -Raw) -replace 'COMPILE_FLAGS /Z7','COMPILE_FLAGS /nologo' | Set-Content CMakeLists.txt -NoNewline" call :build x86 Release MultiThreaded Release call :build x86 Debug MultiThreadedDebug Debug call :build amd64 Release MultiThreaded x64\Release call :build amd64 Debug MultiThreadedDebug x64\Debug if not exist "%~dp0include\hiredis" mkdir "%~dp0include\hiredis" for %%f in (hiredis.h hiredis_ssl.h read.h sds.h alloc.h) do copy /Y %%f "%~dp0include\hiredis\" exit /b 0 :build REM %1 - vcvarsall architecture, %2 - configuration, %3 - CMAKE_MSVC_RUNTIME_LIBRARY, %4 - destination (relative to this script) setlocal call "%VCVARSALL%" %1 -vcvars_ver=14.16 || exit /b 1 "%CMAKE%" -S . -B build-%1-%2 -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=%2 ^ -DBUILD_SHARED_LIBS=OFF -DDISABLE_TESTS=ON -DENABLE_SSL=OFF -DENABLE_NUGET=OFF ^ -DCMAKE_MSVC_RUNTIME_LIBRARY=%3 -DCMAKE_C_FLAGS_DEBUG="/Z7 /Ob0 /Od /RTC1" || exit /b 1 "%CMAKE%" --build build-%1-%2 || exit /b 1 if "%2"=="Debug" (set LIBNAME=hiredisd.lib) else (set LIBNAME=hiredis.lib) if not exist "%~dp0%4" mkdir "%~dp0%4" copy /Y build-%1-%2\%LIBNAME% "%~dp0%4\hiredis.lib" || exit /b 1 endlocal exit /b 0