Giter Club home page Giter Club logo

conan_sdk_packages's Introduction

How to use certain libraries from the underlying system (SDK)?

Purpose

Examples

The example is taken from the openssl test package in the Conan Center Index.

Note that in call cases, linking OpenSSL is done with these two CMake lines:

find_package(OpenSSL REQUIRED)

target_link_libraries(digest OpenSSL::SSL)

Pure CMAKE

Consume the system library using pure CMake.

sudo apt-get install build_essential make gcc cmake libssl-dev

cd pure_cmake
mkdir build
cd build
cmake ..
make
./digest

Consume from Conan Center Index

Consume the openssl library via conan-center-index using conan and CMake.

sudo apt-get install python3 python3-pip
pip3 install conan==1.43.2

cd conan_center_index
conan create .

Consumer cannot override to use the openssl provided by the distribution.

Consume from System with Conan

Consume the openssl library via conan-center-index using conan and CMake.

cd conan_from_system
export CONAN_SYSREQUIRES_MODE=enabled
conan create .

Consumer cannot override to use conan.

Have a dummy system package

Dummy openssl package:

Intermediate library:

Consumer prefering conan:

Consumer prefering system:

cd dummy_system_package
cd openssl_system
conan create . # on Ubuntu 20.04, this will generate openssl/1.1.1f@system/stable
cd ..
cd digest_lib
conan create .
cd ..
cd consumer_cci
conan create .
cd ..
cd consumer_system
conan create . --build=digest_consumer_system --build=digest_lib # digest_lib should be re-built

Result:

  • The consumer can decide where the OpenSSL library should come from. The difference is a single line of code: the requirement override in the consuming conan recipe.
  • No a single adaption in the intermediate library needed!
  • See the digest executable an the respective 'bin' subfolders of the produced packages. Check ldd of these and execute them.

Conditions:

  • "system" package should have the same name as the CCI package so that override works
  • the (most iumportant) options of the CCI package should be reflected in the dummy package (here: option shared)
  • In order to have a real rebuild of the intermediate library, the intermediate lib should use the full_package_mode for the openssl lib. Alternatively, the version can be changed so something non-semver (I use "system" as version, not as channel). But then, the version reflection in openssl_version = tools.Version(self.deps_cpp_info["openssl"].version) would no longer work. And of course any version ranges specified by the consumer.

License

MIT License

conan_sdk_packages's People

Contributors

jngrb avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.