Skip to main content
Topic: template-cpp14

Conan package manager

With this feature you we generate a conan support for your project. It helps with packaging and to managing dependencies for different platforms, OSs, compilers, architecture, cross-builds. Read more about conan and its all benefits here.

File overview for module

With an example API

Hello World API (click to expand)
schema: apigear.module/1.0
version: "1.0.0"

- name: Hello
- { name: last, type: Message }
- name: say
- { name: msg, type: Message }
- { name: when, type: When }
type: int
- name: justSaid
- { name: msg, type: Message }
- name: When
- { name: Now, value: 0 }
- { name: Soon, value: 1 }
- { name: Never, value: 2 }
- name: Message
- { name: content, type: string }

The files for conan will be generated for project:

┣ 📂apigear
┣ 📂cpp_hello_world
┃ ┣ 📂apigear
┃ ┃ ...
┃ ┃ ┗ 📜
┃ ┣ 📂examples
┃ ┃ ┣ 📂 app
┃ ┃ ┃ ...
┃ ┃ ┃ ┗ 📜conanfile.txt
┃ ┃ ...
┃ ┣ 📂modules
┃ ┃ ┗ 📂io_world
┃ ┃ ┃ ┣ 📂conan
┃ ┃ ┃ ┃ ┣ 📂test_package
┃ ┃ ┃ ┃ ┃ ┣ 📜CMakeLists.txt
┃ ┃ ┃ ┃ ┃ ┣ 📜
┃ ┃ ┃ ┃ ┃ ┗ 📜main.cpp
┃ ┃ ┃ ┃ ┗ 📜
┣ 📂scripts
┃ ┣ 📜test_conan.bat
┃ ┣ 📜

Run scripts

The top level files you'll find in '📂hello-world/cpp_hello_world' 📜test_conan.bat (for windows) and 📜 (for linux based systems) contain set of command line commands to build whole project. The scripts build the project twice:

  • Firstly, using a package development commands. This way is recommended for local development, testing and modifications/customization of the build process in the user space without recompiling the entire package. Used command is conan build .. (preceded by source command that copies necessary sources and install command which installs the requirements and generates the info files). You can read more about build here.
  • Secondly, with one of conan creator commands conan create .... It is primarily used to generate, package, and upload packages to a repository. It calls the local ‘package()’ method. The is located in the 📂modules and created for each module separately. Creator Commands are more geared toward recipe creation, versioning, and repository interactions. You can read more about package here.

We use CMake build system with conan.


Modify the script to suit your needs. You can choose one of the building methods depending on current stage of your package development lifecycle.

Some of the above files, the 📂cpp_hello_world/apigear/ or conanfiles.txt generated for each example were present even without conan feature - for simplicity of generation rules.
The 📂cpp_hello_world/apigear/ contains recipe for building additional library - network layer for cpp-template, independent from your API, and necessary for ObjectLink core, for aligning to MQTT protocol or for tracing.
The 📂cpp_hello_world📂modules/io_world/conan/ is the main recipe for your API module, which contains all the info necessary for packaging. Dependencies for the examples are stored in conanfile.txt files in each of the examples ( conanfile.txt is a simplification of, that can be used exclusively to consume dependencies, but not to create packages).

The test package Files inside the 📂cpp_hello_world/modules/io_world/conan/test_package contain a test package. It instantiates Hello implementation from a stub feature. It is a check that package for io_world was created in proper way, can be found and used.