cmake: update vcpkg mod for appveyor build cache

On appveyor we only cache the `vcpkg/installed` directory, so vcpkg
itself still needs to be pulled from git.

Also update vcpkg from git if it has already been cloned, and always
rebuild vcpkg itself.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
Rafael Kitover 2019-10-21 13:58:55 +00:00
parent 0535d5c797
commit c06e3bf3fc
No known key found for this signature in database
GPG Key ID: 08AB596679D86240
1 changed files with 44 additions and 14 deletions

View File

@ -16,25 +16,55 @@ if(VCPKG_TARGET_TRIPLET)
) )
if(NOT git_status EQUAL 0) if(NOT git_status EQUAL 0)
message(FATAL_ERROR "Error cloning vcpkg, please make sure git for windows is installed correctly, it can be installed from Visual Studio components") message(FATAL_ERROR "Error cloning vcpkg from git, please make sure git for windows is installed correctly, it can be installed from Visual Studio components")
endif()
else()
# this is the case when we cache vcpkg/installed with the appveyor build cache
if(NOT EXISTS ${VCPKG_ROOT}/.git)
set(git_commands
"git init"
"git remote add origin https://github.com/microsoft/vcpkg.git"
"git fetch --all --prune"
"git reset --hard origin/master"
"git branch --set-upstream-to=origin/master master"
)
foreach(git_command ${git_commands})
separate_arguments(git_command)
execute_process(
COMMAND ${git_command}
RESULT_VARIABLE git_status
WORKING_DIRECTORY ${VCPKG_ROOT}
)
if(NOT git_status EQUAL 0)
break()
endif()
endforeach()
else()
execute_process(
COMMAND git pull --rebase
RESULT_VARIABLE git_status
WORKING_DIRECTORY ${VCPKG_ROOT}
)
endif()
if(NOT git_status EQUAL 0)
message(FATAL_ERROR "Error updating vcpkg from git, please make sure git for windows is installed correctly, it can be installed from Visual Studio components")
endif() endif()
endif() endif()
# build vcpkg if not built # build latest vcpkg
if(WIN32) if(WIN32)
if(NOT EXISTS ${VCPKG_ROOT}/vcpkg.exe) execute_process(
execute_process( COMMAND bootstrap-vcpkg.bat
COMMAND bootstrap-vcpkg.bat WORKING_DIRECTORY ${VCPKG_ROOT}
WORKING_DIRECTORY ${VCPKG_ROOT} )
)
endif()
else() else()
if(NOT EXISTS ${VCPKG_ROOT}/vcpkg) execute_process(
execute_process( COMMAND ./bootstrap-vcpkg.sh
COMMAND ./bootstrap-vcpkg.sh WORKING_DIRECTORY ${VCPKG_ROOT}
WORKING_DIRECTORY ${VCPKG_ROOT} )
)
endif()
endif() endif()
foreach(pkg ${VCPKG_DEPS}) foreach(pkg ${VCPKG_DEPS})