Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[CMAKE] Set CMAKE_POLICY_VERSION_MINIMUM for samples build (#32079)

Mikhail Ryzhov8ada2b7eb93b
diff --git a/.github/dockerfiles/docker_tag b/.github/dockerfiles/docker_tag
index ce4ea6cccc1..47264d21135 100644
--- a/.github/dockerfiles/docker_tag
+++ b/.github/dockerfiles/docker_tag
@@ -1 +1 @@
-pr-32091
+pr-32079
\ No newline at end of file
diff --git a/.github/dockerfiles/ov_build/ubuntu_22_04_x64/Dockerfile b/.github/dockerfiles/ov_build/ubuntu_22_04_x64/Dockerfile
index f613ab3afb6..c414250216b 100644
--- a/.github/dockerfiles/ov_build/ubuntu_22_04_x64/Dockerfile
+++ b/.github/dockerfiles/ov_build/ubuntu_22_04_x64/Dockerfile
@@ -69,6 +69,11 @@ RUN mkdir ${SCCACHE_HOME} && cd ${SCCACHE_HOME} && \
SCCACHE_ARCHIVE="sccache-${SCCACHE_VERSION}-x86_64-unknown-linux-musl.tar.gz" && \
curl -SLO https://github.com/mozilla/sccache/releases/download/${SCCACHE_VERSION}/${SCCACHE_ARCHIVE} && \
tar -xzf ${SCCACHE_ARCHIVE} --strip-components=1 && rm ${SCCACHE_ARCHIVE}
+
+# Install custom cmake (4.0+)
+RUN wget https://cmake.org/files/v4.1/cmake-4.1.1-linux-x86_64.sh && \
+ sh cmake-4.1.1-linux-x86_64.sh --skip-license --prefix=/usr/local && \
+ rm cmake-4.1.1-linux-x86_64.sh
ENV PATH="$SCCACHE_HOME:$PATH"
# Setup pip
diff --git a/samples/cpp/CMakeLists.txt b/samples/cpp/CMakeLists.txt
index 37a6939cbe4..5f3eb25d10f 100644
--- a/samples/cpp/CMakeLists.txt
+++ b/samples/cpp/CMakeLists.txt
@@ -115,6 +115,10 @@ endif()
if(TARGET gflags)
set(GFLAGS_TARGET gflags)
elseif(gflags_required)
+ # CMake 4.0 and higher will drop support for CMake versions <= 3.5.
+ # By explicitly setting CMAKE_POLICY_VERSION_MINIMUM, we ensure compatibility with dependencies like gflags,
+ # which require at least CMake 3.0.2, and avoid policy warnings or errors in future CMake versions.
+ set(CMAKE_POLICY_VERSION_MINIMUM 3.5)
set(GFLAGS_TARGET gflags_nothreads_static)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/gflags")
add_subdirectory(thirdparty/gflags EXCLUDE_FROM_ALL)