:: Usage: :: - Drag & drop .cpp file on this file from Windows explorer :: - Run from cmd/powershell: :: - > _winpack_build_sample.cmd cpp\opencv_version.cpp :: Requires: :: - CMake :: - MSVS 2015/2017 :: (tools are searched on default paths or environment should be pre-configured) @echo off setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION set SCRIPTDIR=%~dp0 if NOT exist "%SCRIPTDIR%\..\..\build" ( set "MSG=OpenCV Winpack installation is required" goto die ) if [%1]==[] ( set "MSG=Sample path is required" goto die ) if exist %1\* ( set "MSG=Only .cpp samples are allowed (not a directory): %1" goto die ) if NOT "%~x1" == ".cpp" ( set "MSG=Only .cpp samples are allowed: %~x1" goto die ) set SRC_FILENAME=%~dpnx1 echo SRC_FILENAME=!SRC_FILENAME! call :dirname "!SRC_FILENAME!" SRC_DIR echo SRC_DIR=!SRC_DIR! set "SRC_NAME=%~n1" echo SRC_NAME=!SRC_NAME! echo ================================================================================ :: Path to FFMPEG binary files set "PATH=!PATH!;!SCRIPTDIR!\..\..\build\bin\" :: Detect CMake cmake --version >NUL 2>NUL if !ERRORLEVEL! EQU 0 ( set CMAKE_FOUND=1 ) else ( if exist "C:\Program Files\CMake\bin" ( set "PATH=!PATH!;C:\Program Files\CMake\bin" cmake --version >NUL 2>NUL if !ERRORLEVEL! EQU 0 ( set CMAKE_FOUND=1 ) ) ) if NOT DEFINED CMAKE_FOUND ( set "MSG=CMake is required to build OpenCV samples. Download it from here: https://cmake.org/download/ and install into 'C:\Program Files\CMake'" goto die ) else ( echo CMake is detected ) :: Detect compiler cl /? >NUL 2>NUL NUL 2>NUL