@echo off
REM Builds PCRE2 8-bit library (static, without JIT) in 4 variants (Win32/x64 x Release/Debug) with the VS2017 (v141) toolset.
REM Run it from the unpacked pcre2 source directory (see source.url), the results are copied next to this script
REM Parser does not use JIT. Match depth limit is the same as under Unix.
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
call :build x86 Release MultiThreaded Release pcre2-8-static.lib
call :build x86 Debug MultiThreadedDebug Debug pcre2-8-staticd.lib
call :build amd64 Release MultiThreaded x64\Release pcre2-8-static.lib
call :build amd64 Debug MultiThreadedDebug x64\Debug pcre2-8-staticd.lib
if not exist "%~dp0include" mkdir "%~dp0include"
copy /Y build-x86-Release\interface\pcre2.h "%~dp0include\" || exit /b 1
exit /b 0
:build
REM %1 - vcvarsall architecture, %2 - configuration, %3 - CMAKE_MSVC_RUNTIME_LIBRARY, %4 - destination (relative to this script), %5 - name of the built library
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 -DBUILD_STATIC_LIBS=ON -DPCRE2_BUILD_PCRE2_8=ON -DPCRE2_SUPPORT_JIT=OFF -DPCRE2_SUPPORT_UNICODE=ON ^
-DPCRE2_MATCH_LIMIT_DEPTH=10000 -DPCRE2_DEBUG=OFF -DPCRE2_BUILD_PCRE2GREP=OFF -DPCRE2_BUILD_TESTS=OFF ^
-DCMAKE_MSVC_RUNTIME_LIBRARY=%3 -DCMAKE_C_FLAGS_DEBUG="/Z7 /Ob0 /Od /RTC1" || exit /b 1
"%CMAKE%" --build build-%1-%2 --target pcre2-8-static || exit /b 1
if not exist "%~dp0%4" mkdir "%~dp0%4"
copy /Y build-%1-%2\%5 "%~dp0%4\pcre2-8-static.lib" || exit /b 1
endlocal
exit /b 0
E-mail: