Fix #27961: Support reproducible builds by making host system version optional

Add BUILD_INFO_SKIP_SYSTEM_VERSION option to exclude the host kernel version
from build outputs, enabling reproducible builds across systems with different
kernel versions.

Changes:
- Modified CMakeLists.txt to conditionally include CMAKE_HOST_SYSTEM_VERSION
  in the build platform status based on BUILD_INFO_SKIP_SYSTEM_VERSION flag
- Updated 3rdparty/tbb/CMakeLists.txt to set TBB_HOST_VERSION conditionally
- Modified 3rdparty/tbb/version_string.ver.cmakein to use the new variable

When BUILD_INFO_SKIP_SYSTEM_VERSION=ON is set, the host system version is
excluded from both the CMake status output and the TBB version strings,
producing identical binaries on equivalent build systems regardless of
kernel version differences.

Default behavior is unchanged (version included) for backward compatibility.

Fixes #27961
This commit is contained in:
Samaresh Kumar Singh
2025-11-08 09:16:11 -06:00
parent 5fb4ce482c
commit 7224bced8b
3 changed files with 11 additions and 2 deletions

View File

@@ -106,6 +106,11 @@ ocv_warnings_disable(CMAKE_CXX_FLAGS
set(TBB_SOURCE_FILES ${lib_srcs} ${lib_hdrs})
set(tbb_version_file "version_string.ver")
if(NOT BUILD_INFO_SKIP_SYSTEM_VERSION)
set(TBB_HOST_VERSION " ${CMAKE_HOST_SYSTEM_VERSION}")
else()
set(TBB_HOST_VERSION "")
endif()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${tbb_version_file}.cmakein" "${CMAKE_CURRENT_BINARY_DIR}/${tbb_version_file}" @ONLY)
list(APPEND TBB_SOURCE_FILES "${CMAKE_CURRENT_BINARY_DIR}/${tbb_version_file}")

View File

@@ -1,6 +1,6 @@
#define __TBB_VERSION_STRINGS(N) \
#N": BUILD_PACKAGE OpenCV @OPENCV_VERSION@" ENDL \
#N": BUILD_HOST @CMAKE_HOST_SYSTEM_NAME@ @CMAKE_HOST_SYSTEM_VERSION@ @CMAKE_HOST_SYSTEM_PROCESSOR@" ENDL \
#N": BUILD_HOST @CMAKE_HOST_SYSTEM_NAME@@TBB_HOST_VERSION@ @CMAKE_HOST_SYSTEM_PROCESSOR@" ENDL \
#N": BUILD_TARGET @CMAKE_SYSTEM_NAME@ @CMAKE_SYSTEM_VERSION@ @CMAKE_SYSTEM_PROCESSOR@" ENDL \
#N": BUILD_COMPILER @CMAKE_CXX_COMPILER@ (ver @CMAKE_CXX_COMPILER_VERSION@)" ENDL \
#N": BUILD_COMMAND use cv::getBuildInformation() for details" ENDL

View File

@@ -1240,7 +1240,11 @@ endif()
if(OPENCV_TIMESTAMP)
status(" Timestamp:" ${OPENCV_TIMESTAMP})
endif()
status(" Host:" ${CMAKE_HOST_SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_VERSION} ${CMAKE_HOST_SYSTEM_PROCESSOR})
if(NOT BUILD_INFO_SKIP_SYSTEM_VERSION)
status(" Host:" ${CMAKE_HOST_SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_VERSION} ${CMAKE_HOST_SYSTEM_PROCESSOR})
else()
status(" Host:" ${CMAKE_HOST_SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_PROCESSOR})
endif()
if(CMAKE_CROSSCOMPILING)
status(" Target:" ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_VERSION} ${CMAKE_SYSTEM_PROCESSOR})
endif()