aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authornicole mazzuca <mazzucan@outlook.com>2020-07-09 12:32:31 -0700
committerGitHub <noreply@github.com>2020-07-09 12:32:31 -0700
commit3871d733493142a6d31f4f4755fffee5fa8c469c (patch)
tree7da41ed9dc271608a6d095f16db372f13eb417e2 /scripts
parentcb8aa9c2eec1b1fb30181a6964362b104f2e6d2b (diff)
downloadvcpkg-3871d733493142a6d31f4f4755fffee5fa8c469c.tar.gz
vcpkg-3871d733493142a6d31f4f4755fffee5fa8c469c.zip
[vcpkg manifests] fix some issues (#12227)
Fixes #12190 Fixes #12208 Fixes #12234 Fixes #12286 Fixes #12315 Fixes #12186 Fixes #12331 Fixes googleapis/google-cloud-cpp#4487
Diffstat (limited to 'scripts')
-rw-r--r--scripts/azure-pipelines/azure-pipelines.yml4
-rw-r--r--scripts/buildsystems/vcpkg.cmake68
2 files changed, 50 insertions, 22 deletions
diff --git a/scripts/azure-pipelines/azure-pipelines.yml b/scripts/azure-pipelines/azure-pipelines.yml
index 9c66be5a3..80c547633 100644
--- a/scripts/azure-pipelines/azure-pipelines.yml
+++ b/scripts/azure-pipelines/azure-pipelines.yml
@@ -11,6 +11,8 @@ stages:
pool: $(windows-pool)
jobs:
- job:
+ workspace:
+ clean: resources
steps:
- task: Powershell@2
displayName: 'Check C++ Formatting'
@@ -23,6 +25,8 @@ stages:
dependsOn: []
jobs:
- job:
+ workspace:
+ clean: resources
steps:
- task: Powershell@2
displayName: 'Check port manifest Formatting'
diff --git a/scripts/buildsystems/vcpkg.cmake b/scripts/buildsystems/vcpkg.cmake
index 96f847190..4ee79d179 100644
--- a/scripts/buildsystems/vcpkg.cmake
+++ b/scripts/buildsystems/vcpkg.cmake
@@ -6,10 +6,6 @@ option(VCPKG_VERBOSE "Enables messages from the VCPKG toolchain for debugging pu
mark_as_advanced(VCPKG_VERBOSE)
function(_vcpkg_get_directory_name_of_file_above OUT DIRECTORY FILENAME)
- if(DEFINED ${OUT})
- return()
- endif()
-
set(_vcpkg_get_dir_candidate ${DIRECTORY})
while(IS_DIRECTORY ${_vcpkg_get_dir_candidate} AND NOT DEFINED _vcpkg_get_dir_out)
if(EXISTS ${_vcpkg_get_dir_candidate}/${FILENAME})
@@ -28,22 +24,28 @@ function(_vcpkg_get_directory_name_of_file_above OUT DIRECTORY FILENAME)
endfunction()
_vcpkg_get_directory_name_of_file_above(_VCPKG_MANIFEST_DIR ${CMAKE_CURRENT_SOURCE_DIR} "vcpkg.json")
-if(_VCPKG_MANIFEST_DIR)
- set(_VCPKG_MANIFEST_MODE_DEFAULT ON)
-else()
- set(_VCPKG_MANIFEST_MODE_DEFAULT OFF)
-endif()
-
-option(VCPKG_MANIFEST_MODE "Set vcpkg to manifest mode" ${_VCPKG_MANIFEST_MODE_DEFAULT})
-
-if(NOT _VCPKG_MANIFEST_DIR AND VCPKG_MANIFEST_MODE)
+if(NOT DEFINED VCPKG_MANIFEST_MODE)
+ if(_VCPKG_MANIFEST_DIR)
+ set(VCPKG_MANIFEST_MODE ON)
+ else()
+ set(VCPKG_MANIFEST_MODE OFF)
+ endif()
+elseif(VCPKG_MANIFEST_MODE AND NOT _VCPKG_MANIFEST_DIR)
message(FATAL_ERROR
"vcpkg manifest mode was enabled, but we couldn't find a manifest file (vcpkg.json) "
"in any directories above ${CMAKE_CURRENT_SOURCE_DIR}. Please add a manifest, or "
"disable manifests by turning off VCPKG_MANIFEST_MODE.")
endif()
-option(VCPKG_MANIFEST_INSTALL "Install packages from the manifest" ON)
+if(VCPKG_MANIFEST_MODE)
+ option(VCPKG_MANIFEST_INSTALL
+[[
+Install the dependencies listed in your manifest:
+ If this is off, you will have to manually install your dependencies.
+ See https://github.com/microsoft/vcpkg/tree/master/docs/specifications/manifests.md for more info.
+]]
+ ON)
+endif()
# Determine whether the toolchain is loaded during a try-compile configuration
get_property(_CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE)
@@ -198,7 +200,7 @@ endif()
if (NOT DEFINED _VCPKG_INSTALLED_DIR)
if(_VCPKG_MANIFEST_DIR)
- set(_VCPKG_INSTALLED_DIR ${_VCPKG_MANIFEST_DIR}/vcpkg_installed)
+ set(_VCPKG_INSTALLED_DIR ${CMAKE_BINARY_DIR}/vcpkg_installed)
else()
set(_VCPKG_INSTALLED_DIR ${_VCPKG_ROOT_DIR}/installed)
endif()
@@ -230,11 +232,11 @@ else() #Release build: Put Release paths before Debug paths. Debug Paths are req
)
endif()
-# If one CMAKE_FIND_ROOT_PATH_MODE_* variables is set to ONLY, to make sure that ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}
+# If one CMAKE_FIND_ROOT_PATH_MODE_* variables is set to ONLY, to make sure that ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}
# and ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug are searched, it is not sufficient to just add them to CMAKE_FIND_ROOT_PATH,
-# as CMAKE_FIND_ROOT_PATH specify "one or more directories to be prepended to all other search directories", so to make sure that
+# as CMAKE_FIND_ROOT_PATH specify "one or more directories to be prepended to all other search directories", so to make sure that
# the libraries are searched as they are, it is necessary to add "/" to the CMAKE_PREFIX_PATH
-if(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE STREQUAL "ONLY" OR
+if(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE STREQUAL "ONLY" OR
CMAKE_FIND_ROOT_PATH_MODE_LIBRARY STREQUAL "ONLY" OR
CMAKE_FIND_ROOT_PATH_MODE_PACKAGE STREQUAL "ONLY")
list(APPEND CMAKE_PREFIX_PATH "/")
@@ -280,23 +282,45 @@ endforeach()
# CMAKE_EXECUTABLE_SUFFIX is not yet defined
if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
- set(_VCPKG_EXECUTABLE_SUFFIX ".exe")
+ set(_VCPKG_EXECUTABLE "${_VCPKG_ROOT_DIR}/vcpkg.exe")
+ set(_VCPKG_BOOTSTRAP_SCRIPT "${_VCPKG_ROOT_DIR}/bootstrap-vcpkg.bat")
else()
- set(_VCPKG_EXECUTABLE_SUFFIX "")
+ set(_VCPKG_EXECUTABLE "${_VCPKG_ROOT_DIR}/vcpkg")
+ set(_VCPKG_BOOTSTRAP_SCRIPT "${_VCPKG_ROOT_DIR}/bootstrap-vcpkg.sh")
endif()
if(VCPKG_MANIFEST_MODE AND VCPKG_MANIFEST_INSTALL AND NOT _CMAKE_IN_TRY_COMPILE)
+ if(NOT EXISTS "${_VCPKG_EXECUTABLE}")
+ message(STATUS "Bootstrapping vcpkg before install")
+
+ execute_process(
+ COMMAND "${_VCPKG_BOOTSTRAP_SCRIPT}"
+ RESULT_VARIABLE _VCPKG_BOOTSTRAP_RESULT)
+
+ if (NOT _VCPKG_BOOTSTRAP_RESULT EQUAL 0)
+ message(FATAL_ERROR "Bootstrapping vcpkg before install - failed")
+ endif()
+
+ message(STATUS "Bootstrapping vcpkg before install - done")
+ endif()
+
+ message(STATUS "Running vcpkg install")
+
execute_process(
- COMMAND "${_VCPKG_ROOT_DIR}/vcpkg${_VCPKG_EXECUTABLE_SUFFIX}" install
+ COMMAND "${_VCPKG_EXECUTABLE}" install
--triplet ${VCPKG_TARGET_TRIPLET}
--vcpkg-root ${_VCPKG_ROOT_DIR}
--x-manifest-root=${_VCPKG_MANIFEST_DIR}
--x-install-root=${_VCPKG_INSTALLED_DIR}
--binarycaching
RESULT_VARIABLE _VCPKG_INSTALL_RESULT)
+
if (NOT _VCPKG_INSTALL_RESULT EQUAL 0)
- message(FATAL_ERROR "vcpkg install failed")
+ message(FATAL_ERROR "Running vcpkg install - failed")
endif()
+
+ message(STATUS "Running vcpkg install - done")
+
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
"${_VCPKG_MANIFEST_DIR}/vcpkg.json"
"${_VCPKG_INSTALLED_DIR}/vcpkg/status")