scons_logo SCons

SCons can be used both to generate and consume conan packages, via the scons generator generator. The package recipe build() method could be similar to:

class PkgConan(ConanFile):
    settings = 'os', 'compiler', 'build_type', 'arch'
    requires = 'Hello/1.0@user/stable'
    generators = "scons"


    def build(self):
        debug_opt = '--debug-build' if self.settings.build_type == 'Debug' else ''
        # FIXME: Compiler, version, arch are hardcoded, not parametrized
        with tools.chdir("build"):
  'scons -C {}/src {}'.format(self.source_folder, debug_opt))


The SConscript build script can load the generated SConscript_conan file that contains the information of the dependencies, and use it to build

conan = SConscript('{}/SConscript_conan'.format(build_path_relative_to_sconstruct))
if not conan:
    print 'File `SConscript_conan` is missing.'
    print 'It should be generated by running `conan install`.'

flags = conan["conan"]
version = flags.pop("VERSION")
env.Library("hello", "hello.cpp")

A complete example, with a test_package that also uses SCons is in a github repository, you can try it:

$ git clone
$ cd conan-scons-template
$ conan create . demo/testing
> Hello World Release!
$ conan create . demo/testing -s build_type=Debug
> Hello World Debug!