Skip to content

Commit 62c598c

Browse files
authored
Fix build_samples_msvc.bat for CMake 4 (#33899)
Ticket to check if OV has other CMake 4 issues: CVS-180354 Reported to CMake: https://discourse.cmake.org/t/cmake-4-0-treats-in-path-end-as-escaped-quote-on-windows/15487
1 parent 400fedd commit 62c598c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

samples/cpp/build_samples_msvc.bat

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,15 @@ if "%INTEL_OPENVINO_DIR%"=="" (
4343

4444
if exist "%SAMPLES_BUILD_DIR%\CMakeCache.txt" del "%SAMPLES_BUILD_DIR%\CMakeCache.txt"
4545

46-
cd /d "%SAMPLES_SOURCE_DIR%" && cmake -E make_directory "%SAMPLES_BUILD_DIR%" && cd /d "%SAMPLES_BUILD_DIR%" && cmake -DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=ON "%SAMPLES_SOURCE_DIR%"
46+
@REM %SAMPLES_SOURCE_DIR% ends with a backslash. \ escapes
47+
@REM the closing quote in "%SAMPLES_SOURCE_DIR%", causing CMake 4.0+ to treat the
48+
@REM escaped quote as a literal character and produce an invalid path.
49+
@REM Appending \. prevents the trailing \ from escaping the quote, while still
50+
@REM referring to the same directory. Without this, CMake reports the error:
51+
@REM CMake Error: The source directory "<prefix>/samples/cpp"" does not exist.
52+
@REM
53+
@REM Note: `cmake --build "%SAMPLES_BUILD_DIR%"` does not suffer from this issue.
54+
cd /d "%SAMPLES_SOURCE_DIR%" && cmake -E make_directory "%SAMPLES_BUILD_DIR%" && cd /d "%SAMPLES_BUILD_DIR%" && cmake -DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=ON "%SAMPLES_SOURCE_DIR%\."
4755
if ERRORLEVEL 1 GOTO errorHandling
4856

4957
echo.

0 commit comments

Comments
 (0)