Reputation: 7098
I'm trying to use SCons for building a piece of software that depends on a library that is available in sources that are installed in system. For example in /usr/share/somewhere/src
. *.cpp
in that directory should be built into static library and linked with my own code. Library sources have no SConscript
among them.
Since library is in system directory I have no rights and don't want to put build artefacts somewhere under /usr
. /tmp
or .build
in current working directory is OK. I suspect this can be done easily but I've got entangled by all these SConscripts
and VariantDirs
.
env = Environment()
my_things = env.SConscript('src/SConsctipt', variant_dir='.build/my_things')
sys_lib = env.SConscript(????)
result = env.Program('result', [my_things, sys_lib])
What is intended way to solve the problem with SCons?
Upvotes: 4
Views: 840
Reputation: 56438
You could use a Repository to do this. For example, in your SConstruct you could write:
sys_lib = env.SConscript("external.scons", variant_dir=".build/external")
Then in the external.scons
file (which is in your source tree), you add the path to the external source tree and how to build the library therein.
env = Environment()
env.Repository("/usr/share/somewhere/src")
lib = env.Library("library_name", Glob("*.cpp"))
Return("lib")
Upvotes: 3