Некоторая информация о моей системе
Я использую 64-разрядную версию Windows и скачал mingw из winlibs и добавил его в «PATH», а cmake (версия 3.31.3) скачал с официального сайта в виде zip-файла, также добавил его в «PATH», и vcpkg с С помощью руководства добавлено "VCPKG_ROOT" и его путь в качестве переменной среды и еще раз в "PATH".
каталог helloworld:
- vcpkg.json:
"dependencies": [
"fmt"
]
}
- Cmakelists.txt:
project(HelloWorld)
find_package(fmt CONFIG REQUIRED)
add_executable(HelloWorld helloworld.cpp)
target_link_libraries(HelloWorld PRIVATE fmt::fmt)
< /code>
- vcpkg-configuration.json:
< /ul>
{
"default-registry": {
"kind": "git",
"baseline": "80d54ff62d528339c626a6fbc3489a7f25956ade",
"repository": "https://github.com/microsoft/vcpkg"
},
"registries": [
{
"kind": "artifact",
"location": "https://github.com/microsoft/vcpkg-ce-c ... s/main.zip",
"name": "microsoft"
}
]
} - helloworld.cpp:
int main()
{
fmt::print("Hello World!\n");
return 0;
}
< /code>
[*]cmakepresets.json:
< /ul>
{
"version": 2,
"configurePresets": [
{
"name": "vcpkg",
"generator": "MinGW Makefiles",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
}
}
]
}
< /code>
[*]cmakeuserpresets.json:
< /ul>
{
"version": 2,
"configurePresets": [
{
"name": "default",
"inherits": "vcpkg",
"environment": {
"VCPKG_ROOT": "C:/vcpkg"
}
}
]
}
Проблема
После помещения всего этого в каталог helloworld. Я использовал команду «cmake --preset=default» внутри каталога helloworld, и она вывела следующую ошибку:
Preset CMake variables:
CMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake"
Preset environment variables:
VCPKG_ROOT="C:/vcpkg"
-- Running vcpkg install
Fetching registry information from https://github.com/microsoft/vcpkg (HEAD)...
error: in triplet x64-windows: Unable to find a valid Visual Studio instance
Could not locate a complete Visual Studio instance
-- Running vcpkg install - failed
CMake Error at C:/vcpkg/scripts/buildsystems/vcpkg.cmake:904 (message):
vcpkg install failed. See logs for more information:
C:/helloworld/build/vcpkg-manifest-install.log
Call Stack (most recent call first):
C:/cmake/share/cmake-3.31/Modules/CMakeDetermineSystem.cmake:146 (include)
CMakeLists.txt:3 (project)
CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
Я должен упомянуть, что cmake может распознавать «MinGW Makefiles», но без vcpkg.
Поэтому я не думаю, что это проблема в моем «PATH». "или любую переменную среды в моей системе.
Подробнее здесь: https://stackoverflow.com/questions/793 ... sing-vcpkg