diff --git a/docs/users/config-environment.md b/docs/users/config-environment.md index 169b2aff73299f..68d7b04c0c71f6 100644 --- a/docs/users/config-environment.md +++ b/docs/users/config-environment.md @@ -88,3 +88,14 @@ This environment variable changes the metadata of produced NuGet packages. See [ #### VCPKG_USE_NUGET_CACHE This environment variable allows using NuGet's cache for every nuget-based binary source. See [Binary Caching](binarycaching.md#NuGets-cache) for more details. + +#### VCPKG_BUILD_TYPE + +This environment variable allows to select a single build type configuration. +This allows to reduce build times and disk storage requirements locally or in +continuous integration setups. +The environment variable overrides settings in triplet files. +Note that some ports do not support single build type configurations. + +At the moment, the only supported value is: `release`. + diff --git a/scripts/ports.cmake b/scripts/ports.cmake index 4adb481493abde..015fd33092a36e 100644 --- a/scripts/ports.cmake +++ b/scripts/ports.cmake @@ -139,6 +139,9 @@ if(CMD MATCHES "^BUILD$") include("${SCRIPTS}/cmake/z_vcpkg_apply_patches.cmake") include("${SCRIPTS}/cmake/z_vcpkg_prettify_command_line.cmake") + include("${SCRIPTS}/vcpkg_get_tags.cmake") + z_vcpkg_select_build_type() + include("${CURRENT_PORT_DIR}/portfile.cmake") if(DEFINED PORT) include("${SCRIPTS}/build_info.cmake") diff --git a/scripts/vcpkg_get_tags.cmake b/scripts/vcpkg_get_tags.cmake index 749b06e5a9f12c..a6ffd460035ba0 100644 --- a/scripts/vcpkg_get_tags.cmake +++ b/scripts/vcpkg_get_tags.cmake @@ -1,4 +1,18 @@ +macro(z_vcpkg_select_build_type) + if(DEFINED ENV{VCPKG_BUILD_TYPE}) + if(NOT "$ENV{VCPKG_BUILD_TYPE}" STREQUAL "release") + # Cf. https://github.com/microsoft/vcpkg/pull/16110 + message(FATAL_ERROR "The only supported value for VCPKG_BUILD_TYPE is 'release'.") + endif() + set(VCPKG_BUILD_TYPE "$ENV{VCPKG_BUILD_TYPE}") + if(NOT "VCPKG_BUILD_TYPE" IN_LIST VCPKG_ENV_PASSTHROUGH) + # This is for tracking, not for usage by ports. + list(APPEND VCPKG_ENV_PASSTHROUGH "VCPKG_BUILD_TYPE") + endif() + endif() +endmacro() function(vcpkg_get_tags PORT FEATURES VCPKG_TRIPLET_ID VCPKG_ABI_SETTINGS_FILE) + z_vcpkg_select_build_type() message("d8187afd-ea4a-4fc3-9aa4-a6782e1ed9af") vcpkg_triplet_file(${VCPKG_TRIPLET_ID})