0

Using the CMake GUI on Windows, if I select "Specify toolchain file for cross-compiling" I can then provide the explicit path to my vcpkg.cmake file, and my project will Configure, Generate, build and run.

If I instead provide the path using the vcpkg environment variable %VCPKG_ROOT%:

%VCPKG_ROOT%/scripts/buildsystems/vcpkg.cmake

...the CMake Configure step fails with the message:

CMake Error at C:/Program Files/CMake/share/cmake3.23/Modules/CMakeDetermineSystem.cmake:130 (message):
  Could not find toolchain file:
  %VCPKG_ROOT%/scripts/buildsystems/vcpkg.cmake
Call Stack (most recent call first):
  CMakeLists.txt:9 (project)

Is there a way to use the vcpkg environment variable here?

user2023370
  • 10,488
  • 6
  • 50
  • 83
  • If you're interested in reading related source code, see `QCMakeFilePathEditor` and `QCMakeFilePathEditor` in [`Source/QtDialog/QCMakeWidgets.cxx`](https://gitlab.kitware.com/cmake/cmake/-/blob/master/Source/QtDialog/QCMakeWidgets.cxx), and `CMakeSetupDialog::setupFirstConfigure` in [`Source/QtDialog/CMakeSetupDialog.cxx`](https://gitlab.kitware.com/cmake/cmake/-/blob/master/Source/QtDialog/CMakeSetupDialog.cxx). – starball Mar 27 '23 at 23:30
  • How is it related? – user2023370 Mar 28 '23 at 22:16
  • 1
    I believe that's the code for the GUI element where you tried to enter a path with Windows-syntax for environment variable references. I'm assuming that Qt (the UI framework/library that cmake-gui uses doesn't do that be default, at least for the element that CMake used here). You can try to see if CMake bundles special logic to handle Windows-style environment variable references. From a cursory glance, I didn't see any. – starball Mar 28 '23 at 22:32

0 Answers0