-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend triplet detection in CMake toolchain #25529
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -227,6 +227,9 @@ if(NOT DEFINED CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO) | |||||||||||||||||||||||||||||||||||||||||||||||||||||
endif() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
endif() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
if(NOT DEFINED VCPKG_TARGET_TRIPLET AND NOT "$ENV{VCPKG_DEFAULT_TRIPLET}" STREQUAL "") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
endif() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
if(VCPKG_TARGET_TRIPLET) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
# This is required since a user might do: 'set(VCPKG_TARGET_TRIPLET somevalue)' [no CACHE] before the first project() call | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
# Latter within the toolchain file we do: 'set(VCPKG_TARGET_TRIPLET somevalue CACHE STRING "")' which | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -461,10 +464,24 @@ if(VCPKG_MANIFEST_MODE AND VCPKG_MANIFEST_INSTALL AND NOT Z_VCPKG_CMAKE_IN_TRY_C | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
set(Z_VCPKG_ADDITIONAL_MANIFEST_PARAMS) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
if(DEFINED VCPKG_HOST_TRIPLET AND NOT VCPKG_HOST_TRIPLET STREQUAL "") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
list(APPEND Z_VCPKG_ADDITIONAL_MANIFEST_PARAMS "--host-triplet=${VCPKG_HOST_TRIPLET}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
if(NOT DEFINED VCPKG_HOST_TRIPLET OR VCPKG_HOST_TRIPLET STREQUAL "") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see the change to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In particular line 551: vcpkg/scripts/buildsystems/vcpkg.cmake Lines 549 to 574 in ddef0a3
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It really still breaks finding the installed host |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
execute_process( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
COMMAND "${Z_VCPKG_EXECUTABLE}" z-print-config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
--vcpkg-root "${Z_VCPKG_ROOT_DIR}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
OUTPUT_VARIABLE Z_VCPKG_PRINT_CONFIG_LOGTEXT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
ERROR_VARIABLE Z_VCPKG_PRINT_CONFIG_LOGTEXT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
RESULT_VARIABLE Z_VCPKG_PRINT_CONFIG_RESULT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
if("${Z_VCPKG_PRINT_CONFIG_LOGTEXT}" MATCHES [["host_triplet": "([^"][^"]*)"]]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
set(VCPKG_HOST_TRIPLET "${CMAKE_MATCH_1}" CACHE INTERNAL "Host triplet") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
else() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+475
to
+477
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. But I respect the minimum version of CMake supported for user projects, which is 3.7 ATM. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @BillyONeal would prefer to implement a command that only prints the required information ( @ras0219-msft wants this to work for MSBuild too There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems implemented now:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
message(STATUS "Determing host triplet before install - failed") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
z_vcpkg_add_fatal_error("vcpkg install failed. See logs for more information: ${Z_VCPKG_BOOTSTRAP_LOG}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
endif() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
endif() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
list(APPEND Z_VCPKG_ADDITIONAL_MANIFEST_PARAMS "--host-triplet=${VCPKG_HOST_TRIPLET}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
if(VCPKG_OVERLAY_PORTS) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
foreach(Z_VCPKG_OVERLAY_PORT IN LISTS VCPKG_OVERLAY_PORTS) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
list(APPEND Z_VCPKG_ADDITIONAL_MANIFEST_PARAMS "--overlay-ports=${Z_VCPKG_OVERLAY_PORT}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
case should be moved into the if block below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered that, but I preferred to avoid another location which sets
CACHE{VCPKG_TARGET_TRIPLET}
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me a
elseif(NOT "$ENV{VCPKG_DEFAULT_TRIPLET}" STREQUAL "")
is logically clearer.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot make this change because it breaks a common scenario:
VCPKG_DEFAULT_TRIPLET
tox64-windows
because they (rightly) believe it should be the default for unqualified ports in the command line.If a user wants to always use a certain vcpkg triplet, I think the right approach would be to create their own cmake toolchain file with
set(VCPKG_TARGET_TRIPLET ...)\ninclude(../vcpkg.cmake)
, and use$CMAKE_TOOLCHAIN_FILE
to automagically add it to every configure.VCPKG_DEFAULT_TRIPLET
is only intended as a convenience to control the user's CLI interface.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fail to see the point. For new projects, it uses an environment variable named
...DEFAULT...
to override the implicit default, but it doesn't cut the user's option to passVCPKG_TARGET_TRIPLET
to cmake. For existing projects,VCPKG_TARGET_TRIPLET
is cached anyways, so this block will not have an effect.