[Scons-users] Library configuration

Managan, Rob managan1 at llnl.gov
Wed Jun 20 12:11:48 EDT 2012


The approach I took several years ago was to

# file that holds defaults for the platform
defaults = ['myprogram_defaults.py']

opts=Variables(defaults,ARGUMENTS)

opts.Add('hdf_path','Set to path for HDF include and lib directories','',path_validator)
opts.Add('hdf_inc','Set to path for HDF header','',path_validator)
opts.Add('hdf_lib','Set to path for HDF library','',path_validator)

if env['hdf'] == 1:
if env['hdf_path']:
env['hdf_inc'] = os.path.join(env['hdf_path'], 'include')
env['hdf_lib'] = os.path.join(env['hdf_path'], 'lib')


opts.Update(env)
opts.Save(cachefile,env) # to cache results for use next time

Then I use env['hdf_inc'] and env['hdf_lib'] in a routine that checks for the presence of the library and headers using CheckLibwithHeader()
(see a recent email for that routine… http://four.pairlist.net/pipermail/scons-users/2012-June/000073.html)

From: Brady Johnson <bradyallenjohnson at gmail.com<mailto:bradyallenjohnson at gmail.com>>
Reply-To: SCons users mailing list <scons-users at scons.org<mailto:scons-users at scons.org>>
To: SCons users mailing list <scons-users at scons.org<mailto:scons-users at scons.org>>
Subject: Re: [Scons-users] Library configuration

You could definitely implement some command line arguments and use them to pass in paths on-the-fly like you mention. Additionally, SCons has integrated support for functionality similar to autoconf, as can be found here: http://www.scons.org/doc/production/HTML/scons-user/c4132.html

Hope that helps,

Brady

On Wed, Jun 20, 2012 at 5:25 AM, Evan Driscoll <driscoll at cs.wisc.edu<mailto:driscoll at cs.wisc.edu>> wrote:
What's "best practice" for allowing users to specify the location of a
library?


For instance, suppose I have the following file:

// test.cpp
#include <boost/version.hpp>
#if BOOST_VERSION < 104601
# error "You need a newer boost"
#endif

If I compile this on my RHEL 5 office machine with just 'g++ test.cpp', it does
not work. Instead, I have to pass a different include path. What I'm asking is
how do you get that path into the construction environment (without hard-
coding it, of course; assume that option is out)?


There are so many potential choices; I'm trying to figure out if there's a
standard, typical way:

* Look at os.environment at C{,PP,XX,C}FLAGS and LDFLAGS and ParseFlags them
into your environment

* Look at ARGUMENTS (or a Variables object) for *FLAGS

* Look at ARGUMENTS for an argument like "with-boost-incdir=/blah/include"

* Use {Add,Get}Option to look for an argument like "--with-boost-incdir=..."



*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
Rob Managan email managan at llnl.gov
LLNL phone: 925-423-0903
P.O. Box 808, L-095 FAX: 925-422-3389
Livermore, CA 94551-0808
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://four.pairlist.net/pipermail/scons-users/attachments/20120620/255049dc/attachment-0001.html>


More information about the Scons-users mailing list