Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate a pkg-config file: wire-cell-toolkit.pc #221

Merged
merged 1 commit into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions waft/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ def _options(opt, name, incs=None, libs=None):
def _configure(ctx, name, incs=(), libs=(), bins=(), pcname=None, mandatory=True, extuses=()):
lower = name.lower()
UPPER = name.upper()
if pcname is None:
pcname = lower
extuses = list(extuses)

instdir = getattr(ctx.options, 'with_'+lower, None)
Expand All @@ -81,7 +79,10 @@ def _configure(ctx, name, incs=(), libs=(), bins=(), pcname=None, mandatory=True
return

# rely on package config
if not any([instdir,incdir,libdir,bindir]) or (instdir and instdir.lower() in ['yes','on','true']):
no_dirs = not any([instdir,incdir,libdir,bindir])
have_instdir = (instdir and instdir.lower() in ['yes','on','true'])
have_pcname = pcname is not None
if have_pcname and (no_dirs or have_instdir):
ctx.start_msg('Checking for %s in PKG_CONFIG_PATH' % name)
args = "--cflags"
if libs: # things like eigen may not have libs
Expand Down Expand Up @@ -129,6 +130,8 @@ def _configure(ctx, name, incs=(), libs=(), bins=(), pcname=None, mandatory=True
if ctx.is_defined('HAVE_'+UPPER+'_LIB'):
ctx.env['HAVE_'+UPPER] = 1
debug('%s: HAVE %s libs' % (lower, UPPER))
if pcname:
ctx.env.REQUIRES += [pcname]
else:
debug('%s: NO %s libs' % (lower, UPPER))

Expand All @@ -143,6 +146,8 @@ def _configure(ctx, name, incs=(), libs=(), bins=(), pcname=None, mandatory=True
if ctx.is_defined('HAVE_'+UPPER+'_INC'):
ctx.env['HAVE_'+UPPER] = 1
debug('%s: HAVE %s includes' % (lower, UPPER))
if pcname:
ctx.env.REQUIRES += [pcname]
else:
debug('%s: NO %s includes' % (lower, UPPER))

Expand Down
25 changes: 19 additions & 6 deletions waft/wcb.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@
# spdlog is "header only" but use library version for faster recompilation
# wire-cell-util and ZIO both use this
# Need to build with -DCMAKE_POSITION_INDEPENDENT_CODE=ON
('spdlog', dict(incs=['spdlog/spdlog.h'], libs=['spdlog'])),
('spdlog', dict(incs=['spdlog/spdlog.h'], libs=['spdlog'], pcname='spdlog')),

('ZLib', dict(incs=['zlib.h'], libs=['z'])),
('ZLib', dict(incs=['zlib.h'], libs=['z'], pcname='zlib')),
('FFTW', dict(incs=['fftw3.h'], libs=['fftw3f'], pcname='fftw3f')),
('FFTWThreads', dict(libs=['fftw3f_threads'], pcname='fftw3f', mandatory=False)),
('JsonCpp', dict(incs=["json/json.h"], libs=['jsoncpp'])),
('JsonCpp', dict(incs=["json/json.h"], libs=['jsoncpp'], pcname='jsoncpp')),

('Eigen', dict(incs=["Eigen/Dense"], pcname='eigen3')),

# for faster parsing, consider:
# ./wcb configure --with-jsonnet-libs=gojsonnet
('Jsonnet', dict(incs=["libjsonnet.h"], libs=['jsonnet'])),
('TBB', dict(incs=["tbb/parallel_for.h"], libs=['tbb'], mandatory=False)),
('HDF5', dict(incs=["hdf5.h"], libs=['hdf5'], mandatory=False)),
('H5CPP', dict(incs=["h5cpp/all"], mandatory=False, extuses=('HDF5',))),
('TBB', dict(incs=["tbb/parallel_for.h"], libs=['tbb'], pcname='tbb', mandatory=False)),
('HDF5', dict(incs=["hdf5.h"], libs=['hdf5'], pcname='hdf5', mandatory=False)),
('H5CPP', dict(incs=["h5cpp/all"], mandatory=False, extuses=('HDF5',), pcname='h5cpp')),

('ZMQ', dict(incs=["zmq.h"], libs=['zmq'], pcname='libzmq', mandatory=False)),
('CZMQ', dict(incs=["czmq.h"], libs=['czmq'], pcname='libczmq', mandatory=False)),
Expand Down Expand Up @@ -174,6 +174,8 @@ def haveit(one):
cfg.find_program("pandoc", var="PANDOC", mandatory=False)
cfg.find_program("emacs", var="EMACS", mandatory=False)

cfg.env.REQUIRES = list(set(cfg.env.REQUIRES))

debug("dump: " + str(cfg.env))


Expand Down Expand Up @@ -227,6 +229,17 @@ def build(bld):
bld(features="org2pdf", source=readme, target=pdf, name="wct-readme-pdf")
bld.install_files('${PREFIX}/share/doc', pdf)

# Produce a pkg-config .pc file
bld(source='wire-cell-toolkit.pc.in',
name="pkg-config-file",
REQUIRES = ' '.join(bld.env.REQUIRES),
install_path = '${LIBDIR}/pkgconfig/')


# Produce a libtool .la file. This needs one for each lib.
# bld(source='libWireCellXxxx.la.in',
# install_path = '${LIBDIR}')

def dumpenv(bld):
'dump build environment to stdout'

Expand Down
10 changes: 10 additions & 0 deletions wire-cell-toolkit.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
prefix=@prefix@
libdir=@libdir@
includedir=${prefix}/include

Name: wire-cell-toolkit
Description: Toolkit for Liquid Argon TPC Simulation and Reconstruction
Version: @VERSION@
Libs: -L${libdir} @LLIBS@
Cflags: -I${includedir}
Requires: @REQUIRES@