Commit f7e454db authored by Laurent Belcour's avatar Laurent Belcour

[Big Update]

 + Changing the scons scripts for the nonlinear fitters to
use library_available instead of checkPKG.
 + Updating the library_available function to avoid checking the lib +
header when the pkg-config provides a configuration.
 + Adding the #external/build/lib/pkgconfig directory to the list of
directory in the PKG_CONFIG_PATH variable.

[Warning]
Only tested on OSX. Need to be checked with the CI platform.
parent 2f406a9f
......@@ -46,7 +46,7 @@ vars.Add('PYTHON_DIR', 'Python and boost-python libraries directory')
vars.Add('PYTHON_LIB', 'Python and boost-python libraries', default = [])
vars.Add('OPENEXR_INC', 'OpenEXR include directory', default=[])
vars.Add('OPENEXR_LIB', 'OpenEXR libraries', default = [])
vars.Add('OPENEXR_DIR', 'OpenEXR libraries directory',default=[])
vars.Add('OPENEXR_DIR', 'OpenEXR libraries directory', default=[])
vars.Add('FLANN_INC', 'FLANN include directory')
vars.Add('FLANN_DIR', 'FLANN libraries directory')
vars.Add('FLANN_LIB', 'FLANN libraries')
......@@ -61,27 +61,34 @@ vars.Add('CERES_LIB', 'CERES libraries')
vars.Add('CERES_OPT_LIB', 'CERES optional libraries')
vars.Add('NLOPT_INC', 'NLOPT include directory')
vars.Add('NLOPT_DIR', 'NLOPT libraries directory')
vars.Add('NLOPT_LIB', 'NLOPT libraries')
vars.Add('NLOPT_LIB', 'NLOPT libraries', default = [])
vars.Add('NLOPT_OPT_LIB', 'NLOPT optional libraries')
vars.Add('IPOPT_INC', 'IPOPT include directory')
vars.Add('IPOPT_DIR', 'IPOPT libraries directory')
vars.Add('IPOPT_LIB', 'IPOPT libraries')
vars.Add('IPOPT_LIB', 'IPOPT libraries', default = [])
vars.Add('IPOPT_OPT_LIB', 'IPOPT optional libraries')
vars.Add('MATLAB_INC', 'MATLAB include directory')
vars.Add('MATLAB_DIR', 'MATLAB directory')
vars.Add('MATLAB_LIB', 'MATLAB libraries')
# Select user environment variables that we want to honor.
##
# Copy the system environment.
#
# Update the PKG_CONFIG_PATH variable to add the package configuration
# files contained is #external/build/lib/pkgconfig
##
envVars = {}
for var in [ 'PATH', 'CPATH', 'LIBRARY_PATH', 'PKG_CONFIG_PATH',
'TMP', 'TMPDIR' ]:
if var in os.environ:
envVars[var] = os.environ[var]
for var in [ 'PATH', 'CPATH', 'LIBRARY_PATH', 'PKG_CONFIG_PATH', 'TMP', 'TMPDIR' ]:
if var in os.environ:
envVars[var] = os.environ[var]
if len(envVars['PKG_CONFIG_PATH']) > 0:
envVars['PKG_CONFIG_PATH'] += ':'
envVars['PKG_CONFIG_PATH'] += os.path.abspath('external' + os.sep + 'build' + os.sep + 'lib' + os.sep + 'pkgconfig')
env = Environment(variables = vars, ENV = envVars )
# Generate help text for the build variables.
Help(vars.GenerateHelpText(env))
......@@ -98,11 +105,7 @@ if env['PLATFORM'] == 'darwin':
env.AppendUnique(LIBPATH = ['/opt/local/lib/'])
env.AppendUnique(CPPPATH = ['/opt/local/include/'])
#elif env['PLATFORM'] == 'win32':
# Required flag for VS linker
# env['ENV']['TMP'] = os.environ['TMP']
#end
def CheckPKG(context, name):
"""Return True if package NAME can be found with 'pkg-config'."""
......@@ -111,30 +114,36 @@ def CheckPKG(context, name):
context.Result(ret)
return ret
"""
Return True if the given library is available. First look for the LIB_VAR and
INC_VAR construction variables, honoring them if they are defined. Then look
for PKGSPEC using pkg-config. Last, try to build LIB with HEADER. Configure
ENV accordingly.
"""
def library_available(env, pkgspec='', lib='', header='',
language='c++', inc_var='', lib_var=''):
"""Return True if the given library is available. First look for the
LIB_VAR and INC_VAR construction variables, honoring them if
they are defined. Then look for PKGSPEC using pkg-config.
Last, try to build LIB with HEADER. Configure ENV
accordingly.
"""
conf = Configure(env, custom_tests = { 'CheckPKG' : CheckPKG })
if (lib in env) and (len(env[lib]) > 0):
env.AppendUnique(LIBPATH = env[lib_var])
env.AppendUnique(CPPPATH = env[inc_var])
env.AppendUnique(LIBS = env[lib])
elif conf.CheckPKG(pkgspec):
env.ParseConfig('pkg-config --cflags --libs "' + pkgspec + '"')
# Regardless of whether pkg-config succeeded, check whether
# the library is usable.
conf = Configure(env, custom_tests = { 'CheckPKG' : CheckPKG })
result = False
# If a XXX_LIB is specified in the environment, add the various path
# and link flags. Check if the library is correctly compiling and
# linking with the header.
if (lib in env) and (len(env[lib]) > 0):
env.AppendUnique(LIBPATH = env[lib_var])
env.AppendUnique(CPPPATH = env[inc_var])
env.AppendUnique(LIBS = env[lib])
# Check whether the library is usable.
result = conf.CheckLibWithHeader(env[lib], header, language)
conf.Finish()
return result
elif conf.CheckPKG(pkgspec):
env.ParseConfig('pkg-config --cflags --libs "' + pkgspec + '"')
result = True
conf.Finish()
return result
def openexr_available(env):
"""Return True if OpenEXR is available."""
......@@ -172,9 +181,7 @@ conf.Finish()
##
env.AppendUnique(LIBPATH = ['#external/build/lib'])
env.AppendUnique(LIBPATH = ['#sources/build'])
#env.AppendUnique(LIBPATH = ['#build/'])
env.AppendUnique(CPPPATH = ['#external/build/include'])
#env.AppendUnique(CPPPATH = ['#external/build/include/Eigen'])
env.AppendUnique(CPPPATH = ['#sources'])
# Consider files changed as soon as their modification time changes.
......
......@@ -2,7 +2,7 @@ import os
import shutil
import SCons.SConf as C
Import('env', 'CheckPKG')
Import('env', 'CheckPKG', 'library_available')
if env.GetOption('clean'):
print "Removing all the third party packages"
......@@ -18,58 +18,54 @@ if env.GetOption('clean'):
#shutil.rmtree('nlopt-2.4.1', True)
else:
##
# Check for optional dependencies, downloading them if they
# are not already available in the user's environment.
#
# At this point CCFLAGS and LINKFLAGS already contain the
# right flags if those dependencies if they found via
# 'pkg-config'. Check whether they are usable, and download
# them if not.
#
##
conf = Configure(env, custom_tests = { 'CheckPKG' : CheckPKG })
##
# IpOpt dependencies
# Eigen dependency
##
if conf.CheckPKG('ipopt'):
env.ParseConfig('pkg-config --cflags --libs ipopt')
if not conf.CheckLibWithHeader('ipopt', 'coin/IpTNLP.hpp', 'c++'):
execfile('obtain_ipopt.py')
conf = Configure(env, custom_tests = { 'CheckPKG' : CheckPKG })
if conf.CheckPKG('eigen3 >= 3.2.0'):
env.ParseConfig('pkg-config --cflags --libs eigen3')
if not conf.CheckCXXHeader('Eigen/Core'):
execfile('obtain_eigen.py')
env = conf.Finish()
##
# NlOpt dependencies
# The env variable is cloned for IpOpt, NlOpt and CERES to avoid
# propagating the link flags for them in the main build script.
##
if conf.CheckPKG('nlopt >= 2.4.1'):
env.ParseConfig('pkg-config --cflags --libs nlopt')
if not conf.CheckLibWithHeader('nlopt', 'nlopt.hpp', 'c++'):
execfile('obtain_nlopt.py')
env2 = env.Clone()
##
# Check for optional dependencies, downloading them if they
# are not already available in the user's environment.
#
# At this point CCFLAGS and LINKFLAGS already contain the
# right flags if those dependencies if they found via
# 'pkg-config'. Check whether they are usable, and download
# them if not.
#
##
##
# Eigen dependencies
# IpOpt dependencies
##
if conf.CheckPKG('eigen3 >= 3.2.0'):
env.ParseConfig('pkg-config --cflags --libs eigen3')
if not conf.CheckCXXHeader('Eigen/Core'):
execfile('obtain_eigen.py')
if not library_available(env2, pkgspec='ipopt', inc_var='IPOPT_INC', lib_var='IPOPT_DIR', lib='IPOPT_LIB', header='coin/IpTNLP.hpp'):
execfile('obtain_ipopt.py')
env = conf.Finish()
##
# NlOpt dependencies
##
if not library_available(env2, pkgspec='nlopt', inc_var='NLOPT_INC', lib_var='NLOPT_DIR', lib='NLOPT_LIB', header='nlopt.h'):
execfile('obtain_nlopt.py')
##
# CERES dependencies
##
if 'CERES_INC' in env:
if env['CERES_INC'] == ['#external/build/include'] and env['CERES_DIR'] == ['#external/build/lib']:
execfile('obtain_ceres.py')
#end
else:
if not library_available(env2, pkgspec='ceres', inc_var='CERES_INC', lib_var='CERES_DIR', lib='CERES_LIB', header='ceres/ceres.h'):
execfile('obtain_ceres.py')
#end
C.progress_display("external libraries are built as shared libraries")
C.progress_display("please adjust the shared library search path \
before running ALTA")
before running ALTA")
##
# QuadProg++
......@@ -77,14 +73,14 @@ before running ALTA")
qp_target = 'build' + os.sep + 'lib' + os.sep + 'quadprog++'
qp_base = 'quadprog++' + os.sep
qp_sources = [qp_base + 'Array.cc', qp_base + 'QuadProg++.cc']
qp_env = env.Clone()
qp_env = env.Clone()
qp_env.Append(CPPPATH = ['build' + os.sep + 'include'])
if qp_env['CC'] != 'cl':
# We're not building a real static library, but rather what
# Libtool calls a "convenience library": an archive that
# contains PIC code. Thus, force '-fPIC'.
qp_env.AppendUnique(CCFLAGS = ['-fPIC'])
if qp_env['CC'] != 'cl':
# We're not building a real static library, but rather what
# Libtool calls a "convenience library": an archive that
# contains PIC code. Thus, force '-fPIC'.
qp_env.AppendUnique(CCFLAGS = ['-fPIC'])
qp_env.StaticLibrary(target = qp_target, source = qp_sources)
......@@ -15,7 +15,8 @@ if not os.path.exists('.' + os.sep + 'build' + os.sep + 'include' + os.sep + 'gl
if os.name == 'nt':
W.warn(obtain.AltaDependencyWarning, 'sorry, no automatic installation of GLOG')
else:
if sys.platform == 'darwin':
exists_archive = os.path.exists('.' + os.sep + 'glog-0.3.3')
if sys.platform == 'darwin' and not exists_archive:
obtain.patch('glog-0.3.3/src/glog/stl_logging.h.in', 'glog.patch')
C.progress_display('configuring and building GLOG')
obtain.configure_build('glog-0.3.3', '--enable-static=no --enable-shared=true --with-pic=true')
......
import SCons.Warnings as W
Import('env')
Import('env', 'library_available')
env = env.Clone()
env.AppendUnique(LIBS = env['PLUGIN_LIB'])
env.AppendUnique(LIBS = env['CERES_LIB'])
env.AppendUnique(LIBPATH = env['CERES_DIR'])
env.AppendUnique(CPPPATH = env['CERES_INC'])
build_lib = False
conf = Configure(env)
if conf.CheckLibWithHeader(env['CERES_LIB'], 'ceres/ceres.h', 'c++'):
env.AppendUnique(LIBS = env['PLUGIN_LIB'])
if library_available(env, pkgspec='ceres', inc_var='CERES_INC', lib_var='CERES_DIR', lib='CERES_LIB', header='ceres/ceres.h'):
conf = Configure(env)
for lib in env['CERES_OPT_LIB']:
if conf.CheckLib(lib):
env.AppendUnique(LIBS = lib)
else:
W.warn(W.WarningOnByDefault, "could not find library " + lib)
env = conf.Finish()
build_lib = True
else:
W.warn(W.WarningOnByDefault, "unable to find CERES headers or libraries")
env = conf.Finish()
if build_lib:
sources = ['fitter.cpp']
env.SharedLibrary('../../build/nonlinear_fitter_ceres', sources)
env.SharedLibrary('../../build/nonlinear_fitter_ceres', 'fitter.cpp')
#end
Import('env')
Import('env', 'library_available')
env = env.Clone()
env.AppendUnique(LIBS = env['PLUGIN_LIB'])
env.AppendUnique(LIBS = env['IPOPT_LIB'])
env.AppendUnique(LIBPATH = env['IPOPT_DIR'])
env.AppendUnique(CPPPATH = env['IPOPT_INC'])
env.AppendUnique(LIBS = env['PLUGIN_LIB'])
build_lib = False
conf = Configure(env)
if conf.CheckLib(env['IPOPT_LIB']):
if conf.CheckLib(env['IPOPT_OPT_LIB']):
env.AppendUnique(LIBS = env['IPOPT_OPT_LIB'])
#end
build_lib = True
if library_available(env, pkgspec='ipopt', inc_var='IPOPT_INC', lib_var='IPOPT_DIR', lib='IPOPT_LIB', header='coin/IpTNLP.hpp'):
env.SharedLibrary('../../build/nonlinear_fitter_ipopt', 'fitter.cpp')
#end
env = conf.Finish()
if build_lib:
sources = ['fitter.cpp']
env.SharedLibrary('../../build/nonlinear_fitter_ipopt', sources)
#end
\ No newline at end of file
Import('env')
Import('env', 'library_available')
env = env.Clone()
env.AppendUnique(LIBS = env['PLUGIN_LIB'])
env.AppendUnique(LIBS = env['NLOPT_LIB'])
env.AppendUnique(LIBPATH = env['NLOPT_DIR'])
env.AppendUnique(CPPPATH = env['NLOPT_INC'])
#env.AppendUnique(LIBS = env['NLOPT_LIB'])
#env.AppendUnique(LIBPATH = env['NLOPT_DIR'])
#env.AppendUnique(CPPPATH = env['NLOPT_INC'])
build_lib = False
conf = Configure(env)
if library_available(env, pkgspec='nlopt', inc_var='NLOPT_INC', lib_var='NLOPT_DIR', lib='NLOPT_LIB', header='nlopt.h'):
if conf.CheckLib(env['NLOPT_LIB']):
if conf.CheckLib(env['NLOPT_OPT_LIB']):
env.AppendUnique(LIBS = env['NLOPT_OPT_LIB'])
#if conf.CheckLib(env['NLOPT_OPT_LIB']):
# env.AppendUnique(LIBS = env['NLOPT_OPT_LIB'])
#end
build_lib = True
#end
env = conf.Finish()
if build_lib:
sources = ['fitter.cpp']
env.SharedLibrary('../../build/nonlinear_fitter_nlopt', sources)
#end
\ No newline at end of file
#end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment