I am trying to import a library that i installed using vcpkg
(vcpkg install azure-storage-blobs-cpp
)
In my c file I am trying to import azure/storage/blobs.hpp
In my vcpkg directory, i have the following file
./installed/x64-osx/include/azure/storage/blobs.hpp
./packages/azure-storage-blobs-cpp_x64-osx/include/azure/storage/blobs.hpp
vcpkg install azure-storage-blobs-cpp
returns
azure-storage-blobs-cpp provides CMake targets:
# this is heuristically generated, and may not be correct
find_package(azure-storage-blobs-cpp CONFIG REQUIRED)
target_link_libraries(main PRIVATE Azure::azure-storage-blobs)
Here is my cpp file
#include <iostream>
#include <azure/storage/blobs.hpp>
int main() {
std::cout<<"Hello CMake!"<<std::endl;
return 0;
}
Here is my CMAKE file
cmake_minimum_required(VERSION 3.9.1)
project(CMakeHello)
set(CMAKE_CXX_STANDARD 14)
find_package(azure-storage-blobs-cpp CONFIG REQUIRED)
target_link_libraries(main PRIVATE Azure::azure-storage-blobs)
add_executable(cmake_hello azuretest.cpp)
but i am reaching
CMake Error at CMakeLists.txt:7 (find_package):
Could not find a package configuration file provided by
"azure-storage-blobs-cpp" with any of the following names:
azure-storage-blobs-cppConfig.cmake
azure-storage-blobs-cpp-config.cmake
Add the installation prefix of "azure-storage-blobs-cpp" to
CMAKE_PREFIX_PATH or set "azure-storage-blobs-cpp_DIR" to a directory
containing one of the above files. If "azure-storage-blobs-cpp" provides a
separate development package or SDK, be sure it has been installed.
after cmake CMakeLists.txt
How do I import azure/storage/blobs.hpp
?
This is in mac environment
CodePudding user response:
You need to use:
-DCMAKE_TOOLCHAIN_FILE=[path to vcpkg]/scripts/buildsystems/vcpkg.cmake
while configuring your cmake. You can see full guide here. So you need to first correct your cmake as follows:
cmake_minimum_required(VERSION 3.9.1)
project(CMakeHello)
set(CMAKE_CXX_STANDARD 14)
find_package(azure-storage-blobs-cpp CONFIG REQUIRED)
add_executable(cmake_hello azuretest.cpp)
target_link_libraries(cmake_hello PRIVATE Azure::azure-storage-blobs)
then run following commands in your source directory:
cmake -B ./build -S . -DCMAKE_TOOLCHAIN_FILE=[path_to_vcpkg]/scripts/buildsystems/vcpkg.cmake
cmake --build ./build
remember to replace [path_to_vcpkg]
with real path.