Before installation, there are some key points about Conan:
- “Conan is a dependency and package manager for C and C++ languages.”
- “With full binary management, Conan can create and reuse any number of different binaries (for different configurations like architectures, compiler versions, etc.) for any number of different versions of a package, using exactly the same process in all platforms.”
- “As it is decentralized, it is easy to run your own server to host your own packages and binaries privately, without needing to share them.”
- On the server side: “The free JFrog Artifactory Community Edition (CE) is the recommended Conan server to host your own packages privately under your control.”
- On the client side: What one needs is a Conan client.
- Simply put, JFrog for server and Conan for client.
- “Conan is a decentralized package manager with a client-server architecture. This means that clients can fetch packages from, as well as upload packages to, different servers (“remotes”), similar to the “git” push-pull model to/from git remotes.”
- “At a high level, the servers are just storing packages. They do not build nor create the packages. The packages are created by the client, and if binaries are built from sources, that compilation is also done by the client application.”
- “The Conan client: this is a console/terminal command-line application, containing the heavy logic for package creation and consumption. Conan client has a local cache for package storage, and so it allows you to fully create and test packages offline. You can also work offline as long as no new packages are needed from remote servers.”
- “JFrog Artifactory Community Edition (CE) is the recommended Conan server to host your own packages privately under your control. It is a free community edition of JFrog Artifactory for Conan packages, including a WebUI, multiple auth protocols (LDAP), Virtual and Remote repositories to create advanced topologies, a Rest API, and generic repositories to host any artifact.”
- “ConanCenter is a central public repository where the community contributes packages for popular open-source libraries like Boost, Zlib, OpenSSL, Poco, etc.”
- The basic unit of conan project is a package. And a package is defined by a file “conanfile.py” that defines the package’s dependencies, sources, how to build the binaries from sources, etc. One package “conanfile.py” recipe can generate any arbitrary number of binaries, one for each different platform and configuration: operating system, architecture, compiler, build type, etc.
- “These binaries can be created and uploaded to a server with the same commands in all platforms, having a single source of truth for all packages and not requiring a different solution for every different operating system.”
- “Installation of packages from servers is also very efficient. Only the necessary binaries for the current platform and configuration are downloaded, not all of them. If the compatible binary is not available, the package can be built from sources in the client too.”
An example about conanfile.py
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout
class HelloConan(ConanFile):
name = "hello"
version = "0.1"
# Optional metadata
license = "<Put the package license here>"
author = "<Put your name here> <And your email here>"
url = "<Package recipe repository url here, for issues about the package>"
description = "<Description of Hello here>"
topics = ("<Put some tag here>", "<here>", "<and here>")
# Binary configuration
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "fPIC": True}
# Sources are located in the same place as this recipe, copy them to the recipe
exports_sources = "CMakeLists.txt", "src/*", "include/*"
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
def layout(self):
cmake_layout(self)
def generate(self):
tc = CMakeToolchain(self)
tc.generate()
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def package(self):
cmake = CMake(self)
cmake.install()
def package_info(self):
self.cpp_info.libs = ["hello"]
The directory structure of a Conan package
2024/01/20 21:52 <DIR> .
2024/01/20 21:52 <DIR> ..
2023/05/01 17:30 235 CMakeLists.txt
2023/05/01 17:30 1,307 conanfile.py
2023/05/01 16:55 <DIR> include
2023/05/01 17:01 <DIR> src
2 个文件 1,542 字节
4 个目录 66,603,655,168 可用字节
Installation of Conan
# pip install conan
To install Conan using pip, you need Python>=3.6 distribution installed on your machine.文章来源:https://www.toymoban.com/news/detail-828587.html
Installation of JFrog
Download jfrog-artifactory-cpp-ce-7.55.10-linux.tar.gz from web site https://conan.io/downloads, and the Decompression is the Installation.文章来源地址https://www.toymoban.com/news/detail-828587.html
References
- Conan Documentation --Release 1.58.0
到了这里,关于All the stories begin at installation的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!