Conan2: Conceptions & Configurations & Command Lines

Difference between settings and options

• settings are typically a project-wide configuration defined by the client machine.
Things like the operating system, compiler or build configuration that will be common to several Conan packages and would not make sense to define one default value for only one of them.
For example, it doesn’t make sense for a Conan package to declare “Visual Studio” as a default compiler because that is something defined by the end consumer, and unlikely to make sense if they are working in Linux.
• options are intended for package-specific configuration that can be set to a default value in the recipe.
For example, one package can define that its default linkage is static, and this is the linkage that should be used if consumers don’t specify otherwise.

Introducing the concept of Package ID

When consuming packages like Zlib with different settings and options, you might wonder how Conan determines which binary to retrieve from the remote.
The answer lies in the concept of the package_id.

The package_id is an identifier that Conan uses to determine the binary compatibility of packages.
It is computed based on several factors, including the package’s settings, options, and dependencies.
When you modify any of these factors, Conan computes a new package_id to reference the corresponding binary.

Here’s a breakdown of the process:

  1. Determine Settings and Options: Conan first retrieves the user’s input settings and options. These can come from the command line or profiles like –settings=build_type=Debug or –profile=debug.
  2. Compute the Package ID: With the current values for settings, options, and dependencies, Conan computes a hash. This hash serves as the package_id, representing the binary package’s unique identity.
  3. Fetch the Binary: Conan then checks its cache or the specified remote for a binary package with the computed package_id. If it finds a match, it retrieves that binary. If not, Conan can build the package from source or indicate that the binary is missing.

In the context of our tutorial, when we consumed Zlib with different settings and options, Conan used the package_id to ensure that it fetched the correct binary that matched our specified configuration.

specify a directory as local cache path

add a line in file C:\Users\XXXXX\.conan2\global.conf
core.cache:storage_path = Absolute path where the packages and database are stored

create a default profile

> conan profile detect

get the location of the Conan user home

> conan config home

show the contents of the default profile in the /profiles folder

> conan profile show

about --profile argument

These two commands will behave the same:

> conan install . --build=missing
> conan install . --build=missing --profile=default

> 

> 

> 

References

Conan Documentation --Release 2.0.17

你可能感兴趣的:(Conan,Learning,python,c++,c语言)