When I call a builder Program(Target, Source, CXXFLAGS=CompileFlags)
the value of CompileFlags string contains -Wl,-rpath,lib:$ORIGIN/../lib
causing $ORIGIN to be expanded to empty string, while it should be preserved as is.
I tried escaping the dollar sign, adding single quotes inside, nothing helps.
env['RPATH'] = Literal('lib:$ORIGIN/../lib')
also does not work: it produces
g++ -o main -Wl,-rpath=lib:/../lib
in command line even though the man page says "the paths added to RPATH are not transformed by scons in any way" so it supposed to work even without Literal(), I guess.
So how can I add a compiler flag containing $TEXT without SCons trying to expand it as a variable?
Thanks.
You can use double dollars, like this:
env['RPATH'] = Literal('lib:$$ORIGIN/../lib')
I found this can solve the expansion problem
Env['ORIGIN'] = Literal('$ORIGIN')
Env['RPATH'] = Literal('\'$ORIGIN/../lib:lib\'')
Please, let me know if you aware of more proper/elegant solution without.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With