Skip to content

Commit 2f635d4

Browse files
authored
Merge pull request #247 from aminya/vcpkg
fix: skip vcpkg updates based on the requested revision + gracefully warn if doxygen is not installed
2 parents 7fd59c4 + 6557d00 commit 2f635d4

File tree

3 files changed

+40
-20
lines changed

3 files changed

+40
-20
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ jobs:
8080
cppcheck: true
8181
clangtidy: true
8282
task: true
83-
doxygen: true
83+
doxygen: ${{ !contains(matrix.os, 'macos-11') }}
8484

8585
- name: Test
8686
if: ${{ !cancelled() }}

src/Doxygen.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ function(enable_doxygen DOXYGEN_THEME)
7979
endif()
8080

8181
# find doxygen and dot if available
82-
find_package(Doxygen REQUIRED OPTIONAL_COMPONENTS dot)
82+
find_package(Doxygen OPTIONAL_COMPONENTS dot)
83+
if (NOT Doxygen_FOUND)
84+
message(WARNING "Doxygen not found, install doxygen and try again. Documentation will not be generated.")
85+
return()
86+
endif()
8387

8488
# add doxygen-docs target
8589
message(STATUS "Adding `doxygen-docs` target that builds the documentation.")

src/Vcpkg.cmake

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,28 +59,44 @@ macro(_bootstrap_vcpkg)
5959
endmacro()
6060

6161
macro(_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()
86102
endmacro()

0 commit comments

Comments
 (0)