Issue
I've installed Drogon using vcpkg, and in my IDE I have following error:
Package 'Drogon' not found. After installing, regenerate the CMake cache.
vcpkg_rf.txt:
install
drogon
CMakeLists.txt:
# CMakeList.txt : Top-level CMake project file, do global configuration
# and include sub-projects here.
#
cmake_minimum_required (VERSION 3.8)
project ("Drogon Server1")
# Include sub-projects.
add_subdirectory ("Drogon Server1")
# Line below is showing the error
find_package(Drogon CONFIG REQUIRED)
target_link_libraries("Drogon Server1" PRIVATE Drogon::Drogon)
I have found this error also:
CMake Error at C:/Users/MY_USERNAME/Documents/sdk/vcpkg/scripts/buildsystems/vcpkg.cmake:829 (_find_package):
Could not find a package configuration file provided by "Drogon" with any
of the following names:
DrogonConfig.cmake
drogon-config.cmake
Add the installation prefix of "Drogon" to CMAKE_PREFIX_PATH or set
"Drogon_DIR" to a directory containing one of the above files. If "Drogon"
provides a separate development package or SDK, be sure it has been
installed.
Solution
Considering the given information:
Visual Studio 2022
-> Means CMake will default to x64 -> vcpkg will use VCPKG_TARGET_TRIPLET=x64-windows
vcpkg_rf.txt: install drogon
-> Means you use a response file to install drogon. Without specifying the triplet this is x86-windows
As such your triplet used by CMake and vcpkg doesn't agree. Consider using vcpkg in manifest mode by providing a vcpkg.json
with the dependency instead of a response file. This way you won't have a discrepancy in your triplet selection
(As always chanigng this also requires to delete the cmake cache for a clean reconfigure. Furthermore don't have spaces in your target and paths; you are just asking for trouble.)
Answered By - Alexander Neumann Answer Checked By - Senaida (WPSolving Volunteer)