Merge pull request #10473 from alalek:cmake_version_string_timestamp

pull/10512/head
Alexander Alekhin 7 years ago
commit 71f4281080
  1. 19
      cmake/OpenCVUtils.cmake

@ -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)

Loading…
Cancel
Save