question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Configuring error with vcpkg

See original GitHub issue

Brief Issue Summary

I’m using vcpkg to import a logging library (spdlog) with cmake 3.18.0, using this extension, cmake tools.

I followed all the steps in here, successfully downloaded the library I required with the command vcpkg install spdlog and added the command-line argument specified here in the settings.json file like this:

"cmake.configureArgs": [
    "-CMAKE_TOOLCHAIN_FILE:FILEPATH=\"${workspaceFolder}\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake\""
],

And my CMakeLists.txt file looks like this:

cmake_minimum_required(VERSION 3.18.0)
project("Ampoule" VERSION 1.0.0)

file(GLOB_RECURSE SOURCE_FILES CONFIGURE_DEPENDS *.cpp *.h)

find_package(spdlog CONFIG REQUIRED)

add_executable(ampoule ${SOURCE_FILES})

target_link_libraries(main PRIVATE spdlog::spdlog spdlog::spdlog_header_only)

But I’m having an issue while loading the toolchain file (the one specified in the configureArgs) and the configuration fails because cmake is not able to find the package ‘spdlog’ since the vcpkg.make file, the one passed with the -CMAKE_TOOLCHAIN_FILE, fails to load.

Expected:

The project configures successfully and I’m able to #include the library sources into my source code

Apparent Behavior:

The project configuring fails since it is not able to find the package ‘spdlog’

CMake Tools log

The result when configuring (saving the CMakeLists.txt file) is the following:

[main] Configuring folder: Ampoule 
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --no-warn-unused-cli -CMAKE_TOOLCHAIN_FILE:FILEPATH="c:\Users\seriv\Documents\OneDrive\Ampoule\vcpkg\scripts\buildsystems\vcpkg.cmake" -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_C_COMPILER:FILEPATH=C:\MinGW\bin\gcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=C:\MinGW\bin\g++.exe -Hc:/Users/seriv/Documents/OneDrive/Ampoule -Bc:/Users/seriv/Documents/OneDrive/Ampoule/build -G "MinGW Makefiles"
[cmake] Not searching for unused variables given on the command line.
[cmake] loading initial cache file MAKE_TOOLCHAIN_FILE:FILEPATH="c:\Users\seriv\Documents\OneDrive\Ampoule\vcpkg\scripts\buildsystems\vcpkg.cmake"
[cmake] CMake Error: Error processing file: C:/Users/d4n1_/AppData/Local/Programs/Microsoft VS Code/MAKE_TOOLCHAIN_FILE:FILEPATH="c:/Users/seriv/Documents/OneDrive/Ampoule/vcpkg/scripts/buildsystems/vcpkg.cmake"
[cmake] CMake Error at CMakeLists.txt:6 (find_package):
[cmake]   Could not find a package configuration file provided by "spdlog" with any
[cmake]   of the following names:
[cmake] 
[cmake]     spdlogConfig.cmake
[cmake]     spdlog-config.cmake
[cmake] 
[cmake]   Add the installation prefix of "spdlog" to CMAKE_PREFIX_PATH or set
[cmake]   "spdlog_DIR" to a directory containing one of the above files.  If "spdlog"
[cmake]   provides a separate development package or SDK, be sure it has been
[cmake]   installed.
[cmake] 
[cmake] 
[cmake] -- Configuring incomplete, errors occurred!

Notice these two lines, where the file starts loading:

[cmake] loading initial cache file MAKE_TOOLCHAIN_FILE:FILEPATH="c:\Users\seriv\Documents\OneDrive\Ampoule\vcpkg\scripts\buildsystems\vcpkg.cmake"

And when it errors:

[cmake] CMake Error: Error processing file: C:/Users/d4n1_/AppData/Local/Programs/Microsoft VS Code/MAKE_TOOLCHAIN_FILE:FILEPATH="c:/Users/seriv/Documents/OneDrive/Ampoule/vcpkg/scripts/buildsystems/vcpkg.cmake"

The path in the last one looks a bit different and weird.

Platform and Versions

  • Operating System: Windows 10
  • CMake Version: 3.18.0
  • VSCode Version: 1.47.2
  • CMake Tools Extension Version: 1.4.1
  • Compiler/Toolchain: GCC 6.3.0 via MINGW-64

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
alan-wrcommented, Jul 22, 2020

Such as : ctrl + shift + p -> CMake : Edit User-Local CMake Kits { “name”: “my tool chain by toolchain file.”, “toolchainFile”: “c:\Users\seriv\Documents\OneDrive\Ampoule\vcpkg\scripts\buildsystems\vcpkg.cmake” }

0reactions
alan-wrcommented, Jul 28, 2020

@serivesmejia Hi, do you try it by command line?

Read more comments on GitHub >

github_iconTop Results From Across the Web

VCPKG fails to configure when running through cmake ...
Describe the bug $ cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=/mnt/d/dev/vcpkg/scripts/buildsystems/vcpkg.cmake -- Running vcpkg install ...
Read more >
CMake error while using vcpkg and find_package ...
I'm trying to add the header-only library frugally-deep into my CMake project using vcpkg and the findpackage() command. I installed the ...
Read more >
Error while configuring itk example with vcpkg
First, try updating vcpkg, then update the ports. If that does not resolve the problem, submit an issue at vcpkg, as this one...
Read more >
Error when generating CMake with vcpkg
When I open the folder with Visual Studio the generation starts but then I've an error: 1> CMake generation started for configuration: 'x64-Debug'....
Read more >
vcpkg error : How would I fix Build error? - Super User
I am running windows and using vcpkg to install ogre. the issue I am ... Configuring x86-windows -- Building x86-windows-dbg CMake Error at ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found