I having trouble integrating vcpkg package manager with CMake project on Linux. I want to use the doctest library in my project but the same problem exists with other packages too. I performed the following steps.
$ vcpkg install doctest
Computing installation plan...
The following packages will be built and installed:
doctest[core]:x64-linux -> 2.4.9
Detecting compiler hash for triplet "x64-linux"...
Restored 1 packages from /home/bobeff/.cache/vcpkg/archives in 7.67 ms. Use --debug to see more details.
Installing 1/1 doctest:x64-linux...
Elapsed time to handle doctest:x64-linux: 2.183 ms
Total elapsed time: 390 ms
doctest provides CMake targets:
# this is heuristically generated, and may not be correct
find_package(doctest CONFIG REQUIRED)
target_link_libraries(main PRIVATE doctest::doctest)
$ vcpkg integrate install
Applied user-wide integration for this vcpkg root.
CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=/home/bobeff/projects/cpp/vcpkg/scripts/buildsystems/vcpkg.cmake"
- I have a
vcpkg.json
file in the root directory of my project with the following content:
{
"name": "cpp-programming-language",
"version-string": "0.1.0",
"dependencies": [
"doctest"
]
}
$ cmake ../cpp_programming_language/ -DCMAKE_TOOLCHAIN_FILE=/home/bobeff/projects/cpp/vcpkg/scripts/buildsystems/vcpkg.cmake
The last command is giving me the following output:
CMake Error at CMakeLists.txt:7 (find_package):
Could not find a package configuration file provided by "doctest" with any
of the following names:
doctestConfig.cmake
doctest-config.cmake
Add the installation prefix of "doctest" to CMAKE_PREFIX_PATH or set
"doctest_DIR" to a directory containing one of the above files. If
"doctest" provides a separate development package or SDK, be sure it has
been installed.
-- Configuring incomplete, errors occurred!
See also "/home/bobeff/projects/cpp/temp/CMakeFiles/CMakeOutput.log".
When I perform the search for the not found files from the configure error message I have the following output:
$ locate doctestConfig.cmake
/home/bobeff/projects/cpp/vcpkg/buildtrees/doctest/x64-linux-dbg/generated/doctestConfig.cmake
/home/bobeff/projects/cpp/vcpkg/buildtrees/doctest/x64-linux-rel/generated/doctestConfig.cmake
/home/bobeff/projects/cpp/vcpkg/installed/x64-linux/share/doctest/doctestConfig.cmake
/home/bobeff/projects/cpp/vcpkg/packages/doctest_x64-linux/share/doctest/doctestConfig.cmake
Used versions of the programs are as follows:
- CMake
$ cmake --version
cmake version 3.16.3
- vcpkg
$ vcpkg --version
vcpkg package management program version 2022-06-17-9268e366206712e38102b28dbd1617697a99ff2e
- Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.4 LTS
Release: 20.04
Codename: focal