[CPPREST][C++] Suggest Using Conan.io for C++ Dependencies
Description
The current CPPREST generator requires manual dependency management. Developers have to download CPPRest and Boost libraries, extract them, and then manually update the CMakeLists.txt file to point to their location on disk. For a novice with CMake this can be non-trivial.
Conan.io has recently emerged as a viable cross-platform package management system for C++, providing an experience much like maven and nuget, and features CMake support.
For a minimal implementation, the swagger generator would need to create a conanfile.txt and make some slight changes to the current CMakeLists.txt template.
Example: conanfile.txt
[requires] CppRestSdk/2.8.0@ViaviSolutions/stable
[generators] cmake
The CMakeLists.txt file would need to add something like the following two lines:
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
The last change users would have to make is to run the following command in the directory that contains the conanfile.txt:
conan install --build OpenSSL
This is analogous to maven install, which downloads all the required packages and their transitive dependencies to cache, and generates "conanbuildinfo.cmake".
Several lines could then be removed from the existing CMakeLists.txt template. A more experienced CMake person whould be able to define a new template better than I.
Here is a link to the conan.io reference for cmake: http://conanio.readthedocs.io/en/latest/integrations/cmake/cmake_generator.html
@wing328 Would it be possible to make this a CLI option such as --conan=true/false, where a few of the output files will be different depending on the choice?
Would it be possible to make this a CLI option such as --conan=true/false, where a few of the output files will be different depending on the choice?
Thanks for the suggestion, which looks good to me. I'm ok with generating the conanfile.txt file without any CLI option (which means the file should be generated as default)
cc @ravinikam who created the auto-generated CMake file for cpprest generator.
cc @stkrwork as he's been helping on fixing some of the issues with the cpprest generator.
Who will manage the cpprestsdk package on conan.io? or is there an official package on it already, that everyone can use?
There is no official package right now. Last week we moved from conan.io to Bintray, so conan.io is not a server anymore. In bintray there are two repos:
- conan-transit: read-only, with a copy of packages from conan.io. https://bintray.com/conan/conan-transit There are like 4 different versions from different users.
- conan-center: it is a moderated/curated repo: https://bintray.com/conan/conan-center. Right now is empty, the review process has just started.
The goal would be to first have an official package in conan-center. If no official package is possible, then a submission from other user, non-official, will be accepted, given some criteria of quality are met: http://docs.conan.io/en/latest/packaging/bintray/conan_center_guide.html#contributing-packages-to-conan-center
~~The ideal would be to have the CI process release the conan packages in bintray. Conan has helpers and docs to do this.~~
~~The first step would be to check the existing recipes, and contribute the repo them, so they can be developed and debugged first. I can try to make an initial study and proposal, if you want.~~
UPDATE: Sorry I misunderstood the issue. The CppRest package is from Microsoft, so I don't think they will be shortly providing official packages. Also, CppRestSDK depends on other packages, like Boost and OpenSSL, which there are no official packages for them yet in conan-center. I guess it will take a few months until conan-center gets full speed.
Indeed, with Conan moving to Bintray, their moderation system enables "Verified" publishers for Conan so that popular 3rd party packages made available. Conan will work much like Chocolatey.org and Homebrew in this way. Right now the best candidate for CPPRest will be this one:
https://bintray.com/conan/conan-transit/CppRestSdk%3AViaviSolutions
This one has the dependencies correctly mapped:
Boost/1.59.0@lasote/stable from conan.io
CppRestSdk/2.8.0@ViaviSolutions/stable from conan.io
OpenSSL/1.0.2g@ViaviSolutions/stable from conan.io
zlib/1.2.8@lasote/stable from conan.io
ViaviSolutions also has a good build of OpenSSL, so they're likely to become a verified publisher as well. https://www.viavisolutions.com/en-us