cmake: avoid timestamp change of version_string.inc file

This commit is contained in:
Alexander Alekhin 2017-12-30 19:58:57 +00:00
parent 30373d2566
commit 4bd1e3dcbd

View File

@ -519,16 +519,29 @@ endmacro()
if(NOT DEFINED CMAKE_ARGC) # Guard CMake standalone invocations
set(OPENCV_BUILD_INFO_FILE "${CMAKE_BINARY_DIR}/version_string.tmp")
file(REMOVE "${OPENCV_BUILD_INFO_FILE}")
set(OPENCV_BUILD_INFO_STR "" CACHE INTERNAL "")
function(ocv_output_status msg)
message(STATUS "${msg}")
string(REPLACE "\\" "\\\\" msg "${msg}")
string(REPLACE "\"" "\\\"" msg "${msg}")
file(APPEND "${OPENCV_BUILD_INFO_FILE}" "\"${msg}\\n\"\n")
set(OPENCV_BUILD_INFO_STR "${OPENCV_BUILD_INFO_STR}\"${msg}\\n\"\n" CACHE INTERNAL "")
endfunction()
macro(ocv_finalize_status)
set(OPENCV_BUILD_INFO_FILE "${CMAKE_BINARY_DIR}/version_string.tmp")
if(EXISTS "${OPENCV_BUILD_INFO_FILE}")
file(READ "${OPENCV_BUILD_INFO_FILE}" __content)
else()
set(__content "")
endif()
if("${__content}" STREQUAL "${OPENCV_BUILD_INFO_STR}")
#message(STATUS "${OPENCV_BUILD_INFO_FILE} contains the same content")
else()
file(WRITE "${OPENCV_BUILD_INFO_FILE}" "${OPENCV_BUILD_INFO_STR}")
endif()
unset(__content)
unset(OPENCV_BUILD_INFO_STR CACHE)
if(NOT OPENCV_SKIP_STATUS_FINALIZATION)
if(DEFINED OPENCV_MODULE_opencv_core_BINARY_DIR)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${OPENCV_BUILD_INFO_FILE}" "${OPENCV_MODULE_opencv_core_BINARY_DIR}/version_string.inc" OUTPUT_QUIET)