Conan provides two integrations for plain Makefiles:

The Make toolchain (experimental)

Refer to the links above for more detail about each of them. Here we provide a high-level explanation of how these integrations are meant to be used.

If you are using Makefile to build your project you can use one or both of these depending on your needs.

The make generator outputs all the variables related to package dependencies into a file which is named conanbuildinfo.mak. The make toolchain outputs all the variables related to settings, options, and platform into a file which is named conan_toolchain.mak.

To use the generator, indicate it in your conanfile like this:

 class MyConan(ConanFile):
     generators = "make"

To use the toolchain, add the following function to your conanfile:
 class MyConan(ConanFile):
     def toolchain(self):
         tc = Make(self)

NOTE: This can only be used in a and not conanfile.txt.


We are going to use the same example from Getting Started, a MD5 hash calculator app.

This is the main source file for it:

 #include "Poco/MD5Engine.h"
 #include "Poco/DigestStream.h"

 #include <iostream>

 int main(int argc, char** argv)
     Poco::MD5Engine md5;
     Poco::DigestOutputStream ds(md5);
     ds << "abcdefghijklmnopqrstuvwxyz";
     std::cout << Poco::DigestEngine::digestToHex(md5.digest()) << std::endl;
     return 0;

As this project relies on the Poco Libraries we are going to create a with our requirement and also declare the Make generator and Make toolchain. For simplicity, this conanfile declares an empty build and package step. They’re not needed for for the local developer workflow.
 from conans import ConanFile, MakeToolchain

 class MyConan(ConanFile):
     name = "myconan"
     version = "0.1"
     settings = "os", "arch", "compiler", "build_type"
     generators = "make"
     exports_sources = "*"

     def toolchain(self):
         tc = Make(self)

     def build(self):

     def package(self):

In order to use this generator within your project, use the following Makefile as a reference:

 #     Prepare flags from make generator

 include conanbuildinfo.mak

 #     Prepare flags from make toolchain

 include conan_toolchain.mak

 #     Make variables for a sample App

 SRCS          = main.cpp
 OBJS          = main.o

 #     Make Rules

 .PHONY                  :   exe
 exe                     :   $(EXE_FILENAME)

 $(EXE_FILENAME)         :   $(OBJS)

 %.o                     :   $(SRCS)
     g++ -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@

Now we are going to let Conan retrieve the dependencies, generate the dependency information in the file conanbuildinfo.mak, and generate the options and settings information in the file conan_toolchain.mak:

$ conan install .

Then let’s call make to generate our project:

$ make exe

Now you can run your application with ./main.

See also

Complete reference for Make generator
Complete reference for Make toolchain (experimental)