Skip to content

Commit

Permalink
Merge pull request #170 from aminya/vcpkg [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya authored Oct 28, 2022
2 parents dab87c5 + 8a47da6 commit 0efcdec
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/Vcpkg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ macro(run_vcpkg)
STREQUAL
"")
# detect if the head is detached, if so, switch back before calling git pull on a detached head
set(GIT_STATUS "")
set(_vcpkg_git_status "")
execute_process(
COMMAND "${GIT_EXECUTABLE}" "rev-parse" "--abbrev-ref" "--symbolic-full-name" "HEAD"
OUTPUT_VARIABLE GIT_STATUS
OUTPUT_VARIABLE _vcpkg_git_status
WORKING_DIRECTORY "${_vcpkg_args_VCPKG_DIR}"
OUTPUT_STRIP_TRAILING_WHITESPACE)
if("${GIT_STATUS}" STREQUAL "HEAD")
if("${_vcpkg_git_status}" STREQUAL "HEAD")
message(STATUS "Switching back before updating")
execute_process(COMMAND "${GIT_EXECUTABLE}" "switch" "-" WORKING_DIRECTORY "${_vcpkg_args_VCPKG_DIR}")
endif()
Expand All @@ -65,12 +65,24 @@ macro(run_vcpkg)
else()
message(STATUS "Installing vcpkg at ${_vcpkg_args_VCPKG_DIR}")
# clone vcpkg from Github
if("${_vcpkg_args_VCPKG_URL}" STREQUAL "")
set(_vcpkg_args_VCPKG_URL "https://github.com/microsoft/vcpkg.git")
endif()
if(NOT EXISTS "${_vcpkg_args_VCPKG_DIR}")
if("${_vcpkg_args_VCPKG_URL}" STREQUAL "")
set(_vcpkg_args_VCPKG_URL "https://github.com/microsoft/vcpkg.git")
endif()
execute_process(COMMAND "${GIT_EXECUTABLE}" "clone" "${_vcpkg_args_VCPKG_URL}"
WORKING_DIRECTORY "${VCPKG_PARENT_DIR}" COMMAND_ERROR_IS_FATAL LAST)
else()
# ensure that the given vcpkg remote is the current remote
execute_process(
COMMAND "${GIT_EXECUTABLE}" "remote" "-v"
WORKING_DIRECTORY "${VCPKG_PARENT_DIR}" COMMAND_ERROR_IS_FATAL LAST
OUTPUT_VARIABLE _vcpkg_git_remote_info)
string(FIND "${_vcpkg_git_remote_info}" "${_vcpkg_args_VCPKG_URL}" _vcpkg_has_remote)
if(NOT ${_vcpkg_has_remote})
message(
FATAL
"The current vcpkg remote at ${_vcpkg_args_VCPKG_DIR} does not match the given URL ${_vcpkg_args_VCPKG_URL}")
endif()
endif()
# Run vcpkg bootstrap
if(WIN32)
Expand Down

0 comments on commit 0efcdec

Please sign in to comment.