Skip to content
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.cmake] Setup CMAKE_PROGRAM_PATH for the host if possible #23322

Merged
merged 8 commits into from
Mar 4, 2022
Merged
24 changes: 18 additions & 6 deletions scripts/buildsystems/vcpkg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -517,13 +517,25 @@ if(VCPKG_MANIFEST_MODE AND VCPKG_MANIFEST_INSTALL AND NOT Z_VCPKG_CMAKE_IN_TRY_C
endif()
endif()

list(APPEND CMAKE_PROGRAM_PATH "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/tools")
file(GLOB Z_VCPKG_TOOLS_DIRS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/tools/*")
foreach(Z_VCPKG_TOOLS_DIR IN LISTS Z_VCPKG_TOOLS_DIRS)
if(IS_DIRECTORY "${Z_VCPKG_TOOLS_DIR}")
list(APPEND CMAKE_PROGRAM_PATH "${Z_VCPKG_TOOLS_DIR}")
option(VCPKG_DISABLE_SETUP_CMAKE_PROGRAM_PATH "Disable setup of CMAKE_PROGRAM_PATH to vcpkg paths" OFF)
Neumann-A marked this conversation as resolved.
Show resolved Hide resolved
cmake_dependent_option(VCPKG_USE_HOST_TOOLS "Setup CMAKE_PROGRAM_PATH to use host tools" ON "NOT VCPKG_HOST_TRIPLET STREQUAL \"\"" OFF)
Copy link
Contributor

Choose a reason for hiding this comment

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

CMake Warning (dev) at F:/vcpkg/downloads/tools/cmake-3.22.2-windows/cmake-3.22.2-windows-i386/share/cmake-3.22/Modules/CMakeDependentOption.cmake:84 (message):
  Policy CMP0127 is not set: cmake_dependent_option() supports full Condition
  Syntax.  Run "cmake --help-policy CMP0127" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.
Call Stack (most recent call first):
  F:/vcpkg/scripts/buildsystems/vcpkg.cmake:521 (cmake_dependent_option)
  F:/vcpkg/buildtrees/libwebsockets/x64-windows-rel/CMakeFiles/3.22.2/CMakeSystem.cmake:6 (include)
  F:/vcpkg/buildtrees/libwebsockets/x64-windows-rel/CMakeFiles/CMakeTmp/CMakeLists.txt:5 (project)
This warning is for project developers.  Use -Wno-dev to suppress it.

Copy link

@tusharb86 tusharb86 Jul 22, 2022

Choose a reason for hiding this comment

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

@JackBoosY @Neumann-A - I'm seeing the same warning about CMP0127 in our project. I'm using CMake version 3.23.1. Because vcpkg.cmake is wrapped in a cmake_policy push/pop, I can't set a policy outside of the file as it doesn't have any effect ☹️

It seems like the best option is to place a call to cmake_policy(SET CMP0127 NEW) just before the call to cmake_dependent_option. Does that seem like a reasonable fix? If so, I can prepare the change. Thanks!

Choose a reason for hiding this comment

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

I've created an issue to track this here #25985.


if(NOT VCPKG_DISABLE_SETUP_CMAKE_PROGRAM_PATH)
set(tools_base_path "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/tools")
if(VCPKG_USE_HOST_TOOLS)
set(tools_base_path "${VCPKG_INSTALLED_DIR}/${VCPKG_HOST_TRIPLET}/tools")
Copy link
Contributor

Choose a reason for hiding this comment

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

VCPKG_HOST_TRIPLET maybe empty here.
See #23395.

endif()
endforeach()
list(APPEND CMAKE_PROGRAM_PATH "${tools_base_path}")
file(GLOB Z_VCPKG_TOOLS_DIRS "${tools_base_path}/*")
foreach(Z_VCPKG_TOOLS_DIR IN LISTS Z_VCPKG_TOOLS_DIRS)
if(IS_DIRECTORY "${Z_VCPKG_TOOLS_DIR}")
Neumann-A marked this conversation as resolved.
Show resolved Hide resolved
list(APPEND CMAKE_PROGRAM_PATH "${Z_VCPKG_TOOLS_DIR}")
endif()
endforeach()
unset(Z_VCPKG_TOOLS_DIRS)
unset(Z_VCPKG_TOOLS_DIR)
unset(tools_base_path)
endif()

cmake_policy(POP)

Expand Down