Skip to content

Commit

Permalink
Merge pull request #58 from c-dilks/meson
Browse files Browse the repository at this point in the history
build: switch to Meson
  • Loading branch information
gavalian authored Aug 18, 2024
2 parents c1c84a6 + 56be77a commit 1fc0823
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 0 deletions.
45 changes: 45 additions & 0 deletions extensions/dataframes/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
dataframe_headers = files('RHipoDS.hxx')
dataframe_sources = files('RHipoDS.cxx')
dataframe_linkdef = files('RHipoDS_LinkDef.h')

# ROOT stuff
ROOT_config = find_program('root-config')
ROOT_cling = find_program('rootcling')
ROOT_libdir = run_command(ROOT_config, '--libdir', check: true).stdout().strip()
ROOT_incdir = run_command(ROOT_config, '--incdir', check: true).stdout().strip()
ROOT_inc = include_directories(ROOT_incdir)

# generate ROOT dictionary
dataframe_dict = 'HipoDataFrame_Dict.cxx'
dataframe_lib_file = meson.current_build_dir() / 'libHipoDataFrame.so' # FIXME: file extension is platform dependent
dataframe_dict_tgt = custom_target(
'HipoDataFrameDict',
input: dataframe_headers + hipo_headers + hipo_sources + [ dataframe_linkdef ],
output: [ dataframe_dict ],
command: [
ROOT_cling,
'-v2',
'-f', meson.current_build_dir() / dataframe_dict,
'-s', dataframe_lib_file,
'-rml', fs.name(dataframe_lib_file),
'-rmf', fs.parent(dataframe_lib_file) / fs.stem(dataframe_lib_file) + '.rootmap',
lz4_preproc_def,
'-I' + ROOT_incdir,
'-I' + hipo_incdir,
] + dataframe_sources + dataframe_linkdef,
)

# library
dataframe_lib = library(
'HipoDataFrame',
dataframe_sources + [ dataframe_dict_tgt[0] ],
include_directories: [ hipo_inc, ROOT_inc ],
link_with: [ hipo_lib ],
link_args: [ '-L' + ROOT_libdir, '-lCore', '-lROOTDataFrame', '-lROOTVecOps'],
build_rpath: ROOT_libdir,
cpp_args: [ '-Wno-sign-compare' ], # FIXME: fix these warnings
install: true
)
install_headers(dataframe_headers, subdir: meson.project_name())
project_libs += dataframe_lib

57 changes: 57 additions & 0 deletions hipo4/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
hipo_sources = files(
'bank.cpp',
'datastream.cpp',
'dictionary.cpp',
'event.cpp',
'fusion.cpp',
'node.cpp',
'parser.cpp',
'reader.cpp',
'recordbuilder.cpp',
'record.cpp',
'tuple.cpp',
'utils.cpp',
'wrapper.cpp',
'writer.cpp',
)
hipo_headers = files(
'bank.h',
'datastream.h',
'dictionary.h',
'event.h',
'fizika.h',
'fusion.h',
'hipoexceptions.h',
'json.h',
'jsonutil.h',
'node.h',
'parser.h',
'reaction.h',
'reader.h',
'recordbuilder.h',
'record.h',
'tuple.h',
'twig.h',
'utils.h',
'writer.h',
)

hipo_lib = library(
meson.project_name(),
hipo_sources,
dependencies: [lz4_dep],
cpp_args: [ # FIXME: fix the warnings; they are suppressed by these args
'-Wno-sign-compare',
'-Wno-unused-variable',
'-Wno-unused-but-set-variable',
'-Wno-misleading-indentation',
'-Wno-format',
],
install: true
)

install_headers(hipo_headers, subdir: meson.project_name())
project_libs += hipo_lib

hipo_incdir = meson.current_source_dir()
hipo_inc = include_directories('.')
46 changes: 46 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
project(
'hipo4',
'cpp',
meson_version: '>=1.2',
default_options: {
'cpp_std': 'c++17',
'buildtype': 'release',
'libdir': 'lib',
'default_library': 'both',
'pkgconfig.relocatable': 'true',
},
version: '4.2.0',
)

# modules
fs = import('fs')
pkg = import('pkgconfig')

# dependencies
lz4_dep = dependency('liblz4', method: 'pkg-config', version: '>=1.9', fallback: ['lz4', 'liblz4'])
ROOT_dep = dependency('ROOT', method: 'cmake', version: '>=6.28', required: false)

# preprocessor
lz4_preproc_def = '-D__LZ4__'
add_project_arguments(lz4_preproc_def, language: ['cpp'])

# main project builds
project_libs = []
subdir('hipo4')

# extensions
if(get_option('dataframes'))
if(ROOT_dep.found())
subdir('extensions' / 'dataframes')
else
warning('ROOT dependency not found; dataframes extension will NOT be built')
endif
endif

# packaging
pkg.generate(
name: meson.project_name(),
description: 'High Performance Output Data format for experimental Physics',
libraries: project_libs,
requires: [ lz4_dep ],
)
1 change: 1 addition & 0 deletions meson.options
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
option('dataframes', type: 'boolean', value: true, description: 'install HIPO dataframes extension')
12 changes: 12 additions & 0 deletions subprojects/lz4.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[wrap-file]
directory = lz4-1.9.4
source_url = https://github.com/lz4/lz4/archive/v1.9.4.tar.gz
source_filename = lz4-1.9.4.tgz
source_hash = 0b0e3aa07c8c063ddf40b082bdf7e37a1562bda40a0ff5272957f3e987e0e54b
patch_filename = lz4_1.9.4-2_patch.zip
patch_url = https://wrapdb.mesonbuild.com/v2/lz4_1.9.4-2/get_patch
patch_hash = 4f33456cce986167d23faf5d28a128e773746c10789950475d2155a7914630fb
wrapdb_version = 1.9.4-2

[provide]
liblz4 = liblz4_dep

0 comments on commit 1fc0823

Please sign in to comment.