Skip to content

Latest commit

 

History

History
74 lines (58 loc) · 3.5 KB

File metadata and controls

74 lines (58 loc) · 3.5 KB

Conan C/C++ Package Manager

Installation

# Latest version
pip install conan
# Previous versions
pip install -v "conan==1.59.0"

(Unix) Prefer using virtual environment virtualenv over sudo pip install conan for installation.

Usage

  • Remote repositories
# Add repository
conan remote add <repo_name> <repo_url>
# Authenticate for a remote
conan user <user_name> -p <password> -r <remote_name>
# List recipes in remote repo
conan search -r <remote_name>
  • Local cache
# List recipes in local cache
conan search

Local package development flow

# Install the dependencies (if exists any)
# Generates generator files e.g. conaninfo.txt/conanbuildinfo.txt
conan install .\conanfile.py -if .\build\ -pr .\conan\profiles\msvc_win.txt -s build_type=Release

# Build the package
## -if: directory where the generator files are at from previous step
conan build .\conanfile.py -if .\build\

# Since cmake_layout is used in conanfile, the expected cmake build folder is build and it is recommended to place generator files under build so install command uses build dir for install folder.

# Create package and expose it in the local cache.
conan export-pkg .\conanfile.py demo/testing --profile .\conan\profiles\msvc_win.txt -s build_type=Release -bf .\build\

# Test package
conan test .\test_package\ cpp_cmake_scaffold/0.1@demo/testing --build=never -pr .\conan\profiles\msvc_win.txt -s build_type=Release

Misc

  • Using conan with ninja build tool: ninja complains about CMAKE_GENERATOR_PLATFORM being defined.

    1. Make sure you're using CMakeDeps and/or CMakeToolchain generators in conanfile.txt or conanfile.py.
    2. Add tools.cmake.cmaketoolchain:generator=Ninja to your profile txt file under `[conf].
    3. [Windows only] When you run conan install .. for that profile, it will generate conanvcvars.bat under given directory for -if argument. It is used for initializing the required environment for Ninja.

    Before applying step 4, run this bat file from the command line to activate the environment.

    1. Run cmake . -B build -G Ninja ... and other cmake or ninja commands.
  • How to define Components

  • cmake_find_package generator needs to be used with by setting CMAKE_MODULE_PATH and CMAKE_PREFIX_PATH as defined here and in audacity repo

  • Available conan settings and options

  • Host & Build Context

  • cpp_info reference - Required for package_info() method

References

Misc