Skip to content

Support building in specific modes without a custom triplet.#34482

Draft
teo-tsirpanis wants to merge 3 commits intomicrosoft:masterfrom
teo-tsirpanis:build-type
Draft

Support building in specific modes without a custom triplet.#34482
teo-tsirpanis wants to merge 3 commits intomicrosoft:masterfrom
teo-tsirpanis:build-type

Conversation

@teo-tsirpanis
Copy link
Contributor

@teo-tsirpanis teo-tsirpanis commented Oct 13, 2023

This PR introduces the VCPKG_DEFAULT_BUILD_TYPE option in the CMake toolchain file, that provides a default value to VCPKG_BUILD_TYPE when building the ports.

Besides debug or release, this option can also be set to auto. In that case, vcpkg will consider the CMAKE_BUILD_TYPE or CMAKE_CONFIGURATION_TYPES variables, and if all configurations are known (Debug, Release, RelWithDebInfo, MinSizeRel) and map to only debug or release, it will build the ports in only that mode. If VCPKG_DEFAULT_BUILD_TYPE is not specified, or the CMake project is being built in an unknown configuration, the existing behavior is preserved and vcpkg will default to building in both modes.

Let's talk about how it works. When VCPKG_DEFAULT_BUILD_TYPE is specified, its value (after resolving auto) will be passed to the vcpkg tool via the --x-build-type setting, introduced in microsoft/vcpkg-tool#1231. The tool will propagate VCPKG_DEFAULT_BUILD_TYPE when running the portfile in script mode, and ports.cmake will default VCPKG_BUILD_TYPE to VCPKG_DEFAULT_BUILD_TYPE if the latter is specified. This will happen before the triplet file gets included, to allow the triplet to override the build type and maintain compatibility.

VCPKG_DEFAULT_BUILD_TYPE is supported only in manifest mode.

Fixes #10683

Depends on microsoft/vcpkg-tool#1231

@Neumann-A
Copy link
Contributor

Does not fix #1626. The original issue was about adding subdirs for release/debug. But that issue can probably be closed as not planned.

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)

@LilyWangLL LilyWangLL added the category:tool-update The issue is with build tool or build script, which requires update or should be executed correctly label Oct 16, 2023
@teo-tsirpanis
Copy link
Contributor Author

Does not fix #1626.

Thanks, updated to point to #10683 (which is closed with an ask to reopen at the bottom).

@LilyWangLL LilyWangLL marked this pull request as draft November 2, 2023 02:56
@LilyWangLL
Copy link
Contributor

Convert this PR to draft since there is no progress. Please ping us if this PR is ready for review again.

…r is specified.

`VCPKG_DEFAULT_BUILD_TYPE` is passed to the port by the `--x-build-type` tool option.
@dg0yt
Copy link
Contributor

dg0yt commented May 27, 2024

Rebuilding the whole world in CI. Maybe it should be limited to a single triplet for a first discussion.

@teo-tsirpanis
Copy link
Contributor Author

Oops, I updated the branch as a matter of routine. 😟

Can someone with permissions please cancel CI? Thanks and sorry for any disruption.

@dg0yt
Copy link
Contributor

dg0yt commented May 27, 2024

Can someone with permissions please cancel CI? Thanks and sorry for any disruption.

Push something like bff8a33

@teo-tsirpanis
Copy link
Contributor Author

Thanks!

@LilyWangLL LilyWangLL added the depends:different-pr This PR or Issue depends on a PR which has been filed label Sep 12, 2024
@vicroms vicroms added requires:vcpkg-team-review This PR or issue requires someone on the vcpkg team to take a further look. no-stale Issue will not be marked as stale labels Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category:tool-update The issue is with build tool or build script, which requires update or should be executed correctly depends:different-pr This PR or Issue depends on a PR which has been filed no-stale Issue will not be marked as stale requires:vcpkg-team-review This PR or issue requires someone on the vcpkg team to take a further look.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

How do I tell vcpkg to only build the release version on the command line

5 participants