4

Short Version: vcpkg is failing to build a package with the following error:

Unable to determine appropriate CMake MSBuild generator for:
  Windows-x64-v142  
This is because CMake 3.12.4 does not currently have a 'Visual Studio 16
  2019' option.

even though cmake 3.14 is installed. I'd like to tell it to use cmake 3.14

Long Version:

Background:

I'm experimenting with visual studio 2019 and vcpkg. I currently have visual studio 2017 and vcpkg working perfectly.

Setup:

I created a new triplet for the purpose of installing my 14.2 packages alongside my 14.1 packages. This triplet, which I named x64-windows-dynamic-2019-142, is exactly the same as the standard x64-windows triplet, but I added VCPKG_VISUAL_STUDIO_PATH and VCPKG_PLATFORM_TOOLSET to it. The full triplet file looks like:

set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE dynamic)
set(VCPKG_VISUAL_STUDIO_PATH "C:\\Program Files (x86)\\Microsoft Visual 
Studio\\2019\\Community")
set(VCPKG_PLATFORM_TOOLSET "v142")

I pulled vcpkg to be up to date with the newest master branch and re-ran bootstrap-vcpkg.bat.

Problem:

When I run vcpkg install sfml:x64-windows-dynamic-2019-142 It installs many of the dependencies of sfml without error, but fails to install sfml citing the error I mentioned above.

I am confused why the dependencies did not fail to build, but what I'd really like to know is how to get vcpkg to use my installed and up to date CMake so that it can finish the build.

When I run a 'cmake --version' in the same power shell that I'm installing sfml from It returns "cmake version 3.14.0"

lavinrp
  • 43
  • 1
  • 7
  • 1
    I have the exact same problem, also with SFML. Where does vcpkg get the cmake executable from? I couldn't find a cmake.exe in any sub directory of vcpkg. – Timo Mar 30 '19 at 18:01
  • 2
    See https://github.com/Microsoft/vcpkg/issues/5527 and https://github.com/Microsoft/vcpkg/pull/5702 ( cc @Timo ). – Justin Apr 02 '19 at 00:04

1 Answers1

2

Try setting the environment variable VCPKG_FORCE_SYSTEM_BINARIES before invoking vcpkg.exe, i.e.:

C:\vcpkg>set VCPKG_FORCE_SYSTEM_BINARIES=1
C:\vcpkg>vcpkg install sfml:x64-windows-dynamic-2019-142

Note that the tools cmake.exe, git.exe and ninja.exe must be available on the path.

sakra
  • 62,199
  • 16
  • 168
  • 151
  • 1
    Inspect your `PATH` variable. – sakra Apr 09 '19 at 08:30
  • Thanks. This actually has some behavior that I find quite strange. It still did not pick the CMake 3.14 that I have installed and in my path, but rather the version that shipped with Visual studio 2019. What I find even more strange is that the CMake shipped with VS 2019 doesn't seem to be 3.14 as I get an error saying that 2019 Isn't supported (I know its the packaged CMake because I can see the path in the error log). Regardless, this answer did alter the behavior with just about the desired outcome. I'll accept it at the end of the week If we cant find a more consistent way to do it. – lavinrp Apr 09 '19 at 08:36
  • @sakara What exactly should I look for? I have inspected it and can confirm that C:\Program Files/CMake/bin is in my path and that the version of CMake there is 3.14. I don't see anything else in my path that should supersede that. – lavinrp Apr 09 '19 at 08:44
  • 1
    Type `path` on a cmd.exe prompt to see the actual path. Visual Studio (IDE or command prompt) will modify the path. – sakra Apr 09 '19 at 08:48
  • Ah, I am currently running vcpkg from a fresh powershell (with just the recommended environment variable set on top of my standard user ones). I ran '$env:path' in this shell and opened up a cmd and ran 'path'. The output of both did include the CMake 3.14 path. Perhaps the "VCPKG_VISUAL_STUDIO_PATH" That I am setting in the triplet is what is causing the issue. I'll investigate that more tomorrow. – lavinrp Apr 09 '19 at 09:07
  • Fortunately and unfortunately the freetype library (a dependency of SFML) seems to always fail to install via vcpkg now. The upside to this is that I get a consistent error log that prints out the path to the CMake.exe being used. It actually looks like my C:\Program Files\Cmake\bin\Cmake.exe is being used when VCPKG_FORCE_SYSTEM_BINARIES is NOT set. Which I find strange considering the issue that sparked this post. Setting VCPKG_FORCE_SYSTEM_BINARIES to "1" seems to force the CMake installed with Visual Studio to be used. Changing my triplet seems to have no impact. – lavinrp Apr 12 '19 at 05:17