Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/azure-pipelines/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ parameters:
- name: tripletPattern
displayName: 'Enable triplets which contain this substring'
type: string
default: '-'
default: 'STOP'

jobs:
- job: mintsas
Expand Down
48 changes: 48 additions & 0 deletions scripts/buildsystems/vcpkg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,19 @@ Install the dependencies listed in your manifest:
"VCPKG_MANIFEST_MODE"
OFF)

CMAKE_DEPENDENT_OPTION(VCPKG_DEFAULT_BUILD_TYPE [[
Set the configurations to build the dependencies.
Supported values are "release", "debug" or "auto".
* A value of "release" or "debug" will build dependencies only in Release or Debug mode respectively.
* A value of "auto" will try to guess the configurations from the CMAKE_BUILD_TYPE or CMAKE_CONFIGURATION_TYPES variables.
* An empty or unset value will build dependencies in both Release and Debug modes.

The value of this option will be overriden by the VCPKG_BUILD_TYPE variable set by triplet files.
]]
""
"VCPKG_MANIFEST_MODE"
"")

if(VCPKG_MANIFEST_INSTALL)
set(VCPKG_BOOTSTRAP_OPTIONS "${VCPKG_BOOTSTRAP_OPTIONS}" CACHE STRING "Additional options to bootstrap vcpkg" FORCE)
set(VCPKG_OVERLAY_PORTS "${VCPKG_OVERLAY_PORTS}" CACHE STRING "Overlay ports to use for vcpkg install in manifest mode" FORCE)
Expand Down Expand Up @@ -513,6 +526,41 @@ if(VCPKG_MANIFEST_MODE AND VCPKG_MANIFEST_INSTALL AND NOT Z_VCPKG_CMAKE_IN_TRY_C
list(APPEND Z_VCPKG_ADDITIONAL_MANIFEST_PARAMS "--x-no-default-features")
endif()

if(VCPKG_DEFAULT_BUILD_TYPE STREQUAL "auto")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is mostly unnecessary.

The cases are:
Multi Config Generator -> You want both or an override to only use release libs (!windows)
Single Config Generator -> You want one depending on CMAKE_BUILD_TYPE or an override to use release in debug builds. (!windows)

macro(z_vcpkg_process_build_type build_type)
if(${build_type} STREQUAL "Debug")
set(Z_VCPKG_BUILD_TYPE_DEBUG ON)
elseif(${build_type} MATCHES "Release|RelWithDebInfo|MinSizeRel")
set(Z_VCPKG_BUILD_TYPE_RELEASE ON)
else()
set(Z_VCPKG_BUILD_TYPE_UNKNOWN ON)
endif()
endmacro()

get_cmake_property(Z_VCPKG_MULTI_CONFIG_GENERATOR GENERATOR_IS_MULTI_CONFIG)
if(Z_VCPKG_MULTI_CONFIG_GENERATOR)
foreach(Z_VCPKG_BUILD_TYPE IN LISTS CMAKE_CONFIGURATION_TYPES)
z_vcpkg_process_build_type(${Z_VCPKG_BUILD_TYPE})
endforeach()
else()
z_vcpkg_process_build_type(${CMAKE_BUILD_TYPE})
endif()

if(NOT Z_VCPKG_BUILD_TYPE_UNKNOWN)
if(Z_VCPKG_BUILD_TYPE_DEBUG AND NOT Z_VCPKG_BUILD_TYPE_RELEASE)
set(Z_VCPKG_DEFAULT_BUILD_TYPE "debug")
elseif(Z_VCPKG_BUILD_TYPE_RELEASE AND NOT Z_VCPKG_BUILD_TYPE_DEBUG)
set(Z_VCPKG_DEFAULT_BUILD_TYPE "release")
endif()
endif()
elseif(VCPKG_DEFAULT_BUILD_TYPE)
set(Z_VCPKG_DEFAULT_BUILD_TYPE ${VCPKG_DEFAULT_BUILD_TYPE})
endif()

if (Z_VCPKG_DEFAULT_BUILD_TYPE)
list(APPEND Z_VCPKG_ADDITIONAL_MANIFEST_PARAMS "--x-build-type=${Z_VCPKG_DEFAULT_BUILD_TYPE}")
endif()

if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.18")
set(Z_VCPKG_MANIFEST_INSTALL_ECHO_PARAMS ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE)
else()
Expand Down
7 changes: 7 additions & 0 deletions scripts/ports.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ if(CMD STREQUAL "BUILD")
endif()
file(MAKE_DIRECTORY "${CURRENT_BUILDTREES_DIR}" "${CURRENT_PACKAGES_DIR}")

# VCPKG_DEFAULT_BUILD_TYPE is set by the -x-build-type option when installing in manifest mode.
# Set VCPKG_BUILD_TYPE to it right before including the triplet file, to give the triplet file
# a chance to override the build type.
if(VCPKG_DEFAULT_BUILD_TYPE)
set(VCPKG_BUILD_TYPE "${VCPKG_DEFAULT_BUILD_TYPE}")
endif()

include("${CMAKE_TRIPLET_FILE}")

set(HOST_TRIPLET "${_HOST_TRIPLET}")
Expand Down