Skip to content

CMake wrapper for conan C and C++ package manager

License

Notifications You must be signed in to change notification settings

rbrich/cmake-conan

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cmake-conan

Build Status

CMake dependency provider for the Conan C and C++ package manager.

⚠️ Compatibility with Conan 2.0: integration with Conan 2.0 is currently experimental, may have some limitations, and is subject to change, please read below. The code in this branch only supports Conan 2.0.2 and above - if you need Conan 1.x please check the develop branch.

Quickstart with Conan 2.0

Prerequisites:

  • CMake 3.24
  • Conan 2.0.5
  • A CMake-based project that contains a conanfile.txt or conanfile.py to list the required dependencies.

First, clone this repository in the develop2 branch.

git clone https://github.com/conan-io/cmake-conan.git -b develop2

Example project

This repository contains a CMakeLists.txt with an example project that depends on fmt.

cd cmake-conan/example
mkdir build
cmake -B build -S . -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=../conan_provider.cmake -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release

In your own project

  • Ensure you have placed a conanfile.txt or conanfile.py at the root of your project, listing your requirements. You can see conanfile.txt for an example, or check the Conan documentation for conanfile: .txt docs, .py docs.

  • When first invoking CMake to configure the project, pass -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=[path-to-cmake-conan]/conan_provider.cmake. This will ensure that conan install is invoked from within CMake. This integration does not require making any changes to your CMakeLists.txt scripts.

cd [your-project]
mkdir build
cmake -B build -S . -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=[path-to-cmake-conan]/conan_provider.cmake -DCMAKE_BUILD_TYPE=Release

Known limitations with Conan 2.0

  • Only the CMakeDeps generator is specified - for build settings that would otherwise be provided by CMakeToolchain (for example, the compiler itself or other global build settings) please invoke Conan separately as per documentation.
  • Currently this only works such that Conan can satisfy invocations to CMake's find_package. For dependencies that have logic outside of find_package, for example, by making direct calls to find_program, find_library, find_path or find_file, these may not work correctly.
  • When using a single-configuration CMake generator, you must specify a valid CMAKE_BUILD_TYPE (can't be left blank)
  • Deriving Conan settings is currently only supported on the most common platforms with the most popular compilers.

Development, contributors

There are some tests, you can run in python, with pytest, for example:

$ pytest -rA

About

CMake wrapper for conan C and C++ package manager

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 51.1%
  • CMake 48.3%
  • C++ 0.6%