conan.tools.scons

SConsDeps

The SConsDeps is the dependency generator for SCons. It will generate a SConscript_conandeps file containing the necessary information for SCons to build against the desired dependencies.

The SConsDeps generator can be used by name in conanfiles:

conanfile.py

  1. from conan import ConanFile
  2. class Pkg(ConanFile):
  3. generators = "SConsDeps"

conanfile.txt

  1. [generators]
  2. SConsDeps

It can also be fully instantiated in the conanfile generate() method:

  1. from conan import ConanFile
  2. from conan.tools.scons import SConsDeps
  3. class App(ConanFile):
  4. settings = "os", "arch", "compiler", "build_type"
  5. def generate(self):
  6. tc = SConsDeps(self)
  7. tc.generate()

After executing the conan install command, the SConsDeps generator will create the SConscript_conandeps file. This file will provide the following information for SCons: CPPPATH, LIBPATH, BINPATH, LIBS, FRAMEWORKS, FRAMEWORKPATH, CPPDEFINES, CXXFLAGS, CCFLAGS, SHLINKFLAGS, and LINKFLAGS. This information is generated for the accumulated list of all dependencies and also for each one of the requirements. You can load it in your consumer SConscript like this:

consumer SConscript

  1. ...
  2. info = SConscript('./SConscript_conandeps')
  3. # You can use conandeps to get the information
  4. # for all the dependencies.
  5. flags = info["conandeps"]
  6. # Or use the name of the requirement if
  7. # you only want the information about that one.
  8. flags = info["zlib"]
  9. env.MergeFlags(flags)
  10. ...