-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
[vcpkg] Controlling top-level find_package #27950
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 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -782,6 +782,29 @@ macro("${VCPKG_OVERRIDE_FIND_PACKAGE_NAME}" z_vcpkg_find_package_package_name) | |||||||||||
set(z_vcpkg_find_package_${z_vcpkg_find_package_backup_id}_ARGN "${ARGN}") | ||||||||||||
set(z_vcpkg_find_package_${z_vcpkg_find_package_backup_id}_backup_vars "") | ||||||||||||
|
||||||||||||
if(z_vcpkg_find_package_backup_id EQUAL "1") | ||||||||||||
if(VCPKG_FIND_PACKAGE_${z_vcpkg_find_package_package_name}) | ||||||||||||
# Avoid CMake warning when both REQUIRED and CMAKE_REQUIRE_FIND_PACKAGE_<Pkg> are used | ||||||||||||
if(NOT "REQUIRED" IN_LIST z_vcpkg_find_package_${z_vcpkg_find_package_backup_id}_ARGN) | ||||||||||||
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. Stupid question: Why is |
||||||||||||
list(APPEND z_vcpkg_find_package_${z_vcpkg_find_package_backup_id}_backup_vars "CMAKE_REQUIRE_FIND_PACKAGE_${z_vcpkg_find_package_package_name}") | ||||||||||||
set(z_vcpkg_find_package_${z_vcpkg_find_package_backup_id}_backup_CMAKE_REQUIRE_FIND_PACKAGE_${z_vcpkg_find_package_package_name} "${CMAKE_REQUIRE_FIND_PACKAGE_${z_vcpkg_find_package_package_name}}") | ||||||||||||
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. Stupid question: How does this do the right thing if CMAKE_REQUIRE_FIND_PACKAGE_Blah is undefined? It looks like the backup/restore thingy below would make it be empty string instead? 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. Yeah I think this is wrong and it should be:
Suggested change
Ditto below for the 'disable' arm 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. Also, should we always backup and restore both the |
||||||||||||
set(CMAKE_REQUIRE_FIND_PACKAGE_${z_vcpkg_find_package_package_name} 1) | ||||||||||||
endif() | ||||||||||||
if(VCPKG_TRACE_FIND_PACKAGE) | ||||||||||||
message(STATUS " (required by VCPKG_FIND_PACKAGE_${z_vcpkg_find_package_package_name}=${VCPKG_FIND_PACKAGE_${z_vcpkg_find_package_package_name}})") | ||||||||||||
endif() | ||||||||||||
elseif(DEFINED VCPKG_FIND_PACKAGE_${z_vcpkg_find_package_package_name}) | ||||||||||||
list(APPEND z_vcpkg_find_package_${z_vcpkg_find_package_backup_id}_backup_vars "CMAKE_DISABLE_FIND_PACKAGE_${z_vcpkg_find_package_package_name}") | ||||||||||||
set(z_vcpkg_find_package_${z_vcpkg_find_package_backup_id}_backup_CMAKE_DISABLE_FIND_PACKAGE_${z_vcpkg_find_package_package_name} "${CMAKE_DISABLE_FIND_PACKAGE_${z_vcpkg_find_package_package_name}}") | ||||||||||||
set(CMAKE_DISABLE_FIND_PACKAGE_${z_vcpkg_find_package_package_name} 1) | ||||||||||||
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 seems like this would result in the value being still disabled in transitive Oh, Bill is an idiot:
Suggested change
|
||||||||||||
if(VCPKG_TRACE_FIND_PACKAGE) | ||||||||||||
message(STATUS " (disabled by VCPKG_FIND_PACKAGE_${z_vcpkg_find_package_package_name}=${VCPKG_FIND_PACKAGE_${z_vcpkg_find_package_package_name}})") | ||||||||||||
endif() | ||||||||||||
elseif(VCPKG_TRACE_FIND_PACKAGE) | ||||||||||||
message(STATUS " (could be controlled by VCPKG_FIND_PACKAGE_${z_vcpkg_find_package_package_name})") | ||||||||||||
endif() | ||||||||||||
endif() | ||||||||||||
|
||||||||||||
# Workaround to set the ROOT_PATH until upstream CMake stops overriding | ||||||||||||
# the ROOT_PATH at apple OS initialization phase. | ||||||||||||
# See https://gitlab.kitware.com/cmake/cmake/merge_requests/3273 | ||||||||||||
|
@@ -797,7 +820,10 @@ macro("${VCPKG_OVERRIDE_FIND_PACKAGE_NAME}" z_vcpkg_find_package_package_name) | |||||||||||
string(TOLOWER "${z_vcpkg_find_package_package_name}" z_vcpkg_find_package_lowercase_package_name) | ||||||||||||
set(z_vcpkg_find_package_vcpkg_cmake_wrapper_path | ||||||||||||
"${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/share/${z_vcpkg_find_package_lowercase_package_name}/vcpkg-cmake-wrapper.cmake") | ||||||||||||
if(EXISTS "${z_vcpkg_find_package_vcpkg_cmake_wrapper_path}") | ||||||||||||
if(CMAKE_DISABLE_FIND_PACKAGE_${z_vcpkg_find_package_package_name}) | ||||||||||||
# Skip wrappers, fail if REQUIRED. | ||||||||||||
_find_package("${z_vcpkg_find_package_package_name}" ${z_vcpkg_find_package_${z_vcpkg_find_package_backup_id}_ARGN}) | ||||||||||||
elseif(EXISTS "${z_vcpkg_find_package_vcpkg_cmake_wrapper_path}") | ||||||||||||
if(VCPKG_TRACE_FIND_PACKAGE) | ||||||||||||
string(REPEAT " " "${z_vcpkg_find_package_backup_id}" z_vcpkg_find_package_indent) | ||||||||||||
message(STATUS "${z_vcpkg_find_package_indent}using share/${z_vcpkg_find_package_lowercase_package_name}/vcpkg-cmake-wrapper.cmake") | ||||||||||||
|
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.