scons_logo SConsΒΆ


This is a deprecated feature. Please refer to the Migration Guidelines to find the feature that replaced this one.

SCons can be used both to generate and consume Conan packages via the scons 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_opts = ['--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_opts)


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 uses SCons too is available in the following GitHub repository. Give it a try!

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