I downloaded the last version of Conan from here and then I've done the following.
- Creating a new c++ project with the following code
main.cpp
#include "Poco/MD5Engine.h"
#include "Poco/DigestStream.h"
#include <iostream>
int main(int argc, char** argv)
{
Poco::MD5Engine md5;
Poco::DigestOutputStream ds(md5);
ds << "abcdefghijklmnopqrstuvwxyz";
ds.close();
std::cout << Poco::DigestEngine::digestToHex(md5.digest()) << std::endl;
return 0;
}
CMakeList.txt
cmake_minimum_required(VERSION 3.25)
project(TestMailPrj)
set(CMAKE_CXX_STANDARD 20)
find_package(poco REQUIRED)
add_executable(TestMailPrj main.cpp)
target_link_libraries(${PROJECT_NAME} POCO)
conanfile.txt
[requires]
cmake/3.25.3
poco/1.12.4
[generators]
CMakeDeps
CMakeToolchain
- Run the following command:
conan install . --output-folder=build --build=missing
Now, even if my all dependencies were installed properly, in CMakeFile it can not find my Poco library.
By not providing "Findpoco.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "poco", but CMake did not find one.
Could not find a package configuration file provided by "poco" with any of the following names:
pocoConfig.cmake
poco-config.cmake
Add the installation prefix of "poco" to CMAKE_PREFIX_PATH or set "poco_DIR" to a directory containing one of the above files. If "poco" provides a separate development package or SDK, be sure it has been installed.
Dose anyone knows what exactly I am doing wrong or this is a bug?
Your example is almost good to be built, but needs some updates:
The
cmake
package is tool requirement, not a regular build, as you will need to run cmake only when building your project, not for runtime. Thus, you need to update yourconanfile.txt
to:Second, you
CMakeLists.txt
is looking forpoco
target, but Conan will generateFindPoco.cmake
instead, so you need to update not only it, but also the target:You really don't need C++20 here, C++11 is enough for your example, so I updated it. Plus, you are using MD5Engine and DigestStream that are part of
Crypto
module. TheFoundation
module is basic and always needed. You could usePoco::Poco
module instead, it's generated by Conan and includes all modules.Your installation command is correct:
Now, we need to build the project:
It's important to note two things here:
For further learning, I recommend you reading the Build a simple CMake project using Conan tutorial.