@@ -59,28 +59,44 @@ macro(_bootstrap_vcpkg)
5959endmacro ()
6060
6161macro (_is_vcpkg_outdated )
62- if ("${_vcpkg_args_VCPKG_UPDATE_THRESHOLD} " STREQUAL "" )
63- set (_vcpkg_args_VCPKG_UPDATE_THRESHOLD 3600)
64- endif ()
62+ # skip the update if the requested revision is the same as the current revision
63+ git_revision (_REVISION REPOSITORY_PATH "${_vcpkg_args_VCPKG_DIR} " )
64+ if (NOT "${_vcpkg_args_VCPKG_REV} " STREQUAL "" AND "${_REVISION} " STREQUAL
65+ "${_vcpkg_args_VCPKG_REV} "
66+ )
67+ message (STATUS "Skipping vcpkg update as it's already at ${_REVISION} " )
68+ set (_vcpkg_args_ENABLE_VCPKG_UPDATE OFF )
69+ elseif (NOT "${_vcpkg_args_VCPKG_REV} " STREQUAL "" AND NOT "${_REVISION} " STREQUAL
70+ "${_vcpkg_args_VCPKG_REV} "
71+ )
72+ # Requested revision is different from the current revision, so update
73+ set (_vcpkg_args_ENABLE_VCPKG_UPDATE ON )
74+ else ()
75+ # Requested revision is not specified, so update depending on the timestamp
76+ # Check if the vcpkg registry is updated using the timestamp file that project_option generates
77+ if ("${_vcpkg_args_VCPKG_UPDATE_THRESHOLD} " STREQUAL "" )
78+ set (_vcpkg_args_VCPKG_UPDATE_THRESHOLD 3600)
79+ endif ()
6580
66- if (${_vcpkg_args_ENABLE_VCPKG_UPDATE} )
67- set (_time_stamp_file "${VCPKG_PARENT_DIR} /.vcpkg_last_update" )
68-
69- if (EXISTS "${_time_stamp_file} " )
70- string (TIMESTAMP _current_time "%s" )
71- file (TIMESTAMP "${_time_stamp_file} " _vcpkg_last_update "%s" )
72- # if the last update was more than VCPKG_UPDATE_THRESHOLD
73- math (EXPR time_diff "${_current_time} - ${_vcpkg_last_update} " )
74- if (${time_diff} GREATER ${_vcpkg_args_VCPKG_UPDATE_THRESHOLD} )
81+ if (${_vcpkg_args_ENABLE_VCPKG_UPDATE} )
82+ set (_time_stamp_file "${VCPKG_PARENT_DIR} /.vcpkg_last_update" )
83+
84+ if (EXISTS "${_time_stamp_file} " )
85+ string (TIMESTAMP _current_time "%s" )
86+ file (TIMESTAMP "${_time_stamp_file} " _vcpkg_last_update "%s" )
87+ # if the last update was more than VCPKG_UPDATE_THRESHOLD
88+ math (EXPR time_diff "${_current_time} - ${_vcpkg_last_update} " )
89+ if (${time_diff} GREATER ${_vcpkg_args_VCPKG_UPDATE_THRESHOLD} )
90+ set (_vcpkg_args_ENABLE_VCPKG_UPDATE ON )
91+ file (TOUCH "${_time_stamp_file} " )
92+ else ()
93+ message (STATUS "vcpkg updated recently. Skipping update." )
94+ set (_vcpkg_args_ENABLE_VCPKG_UPDATE OFF )
95+ endif ()
96+ else ()
7597 set (_vcpkg_args_ENABLE_VCPKG_UPDATE ON )
7698 file (TOUCH "${_time_stamp_file} " )
77- else ()
78- message (STATUS "vcpkg updated recently. Skipping update." )
79- set (_vcpkg_args_ENABLE_VCPKG_UPDATE OFF )
8099 endif ()
81- else ()
82- set (_vcpkg_args_ENABLE_VCPKG_UPDATE ON )
83- file (TOUCH "${_time_stamp_file} " )
84100 endif ()
85101 endif ()
86102endmacro ()
0 commit comments