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

Add meson buildsystem #275

Merged
merged 1 commit into from
May 23, 2024
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
46 changes: 46 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#
# See COPYING for more information about licensing
#

project('nethogs',
['c', 'cpp'],
default_options : ['warning_level=3',
'cpp_std=c++14']
)

cc = meson.get_compiler('cpp')
version = run_command('./determineVersion.sh', check: true).stdout().strip()

#######################################
## Dependencies and flags definition ##
#######################################
# directories
projectinc = [include_directories('.', 'src')]

# flags
c_args = [
'-DVERSION="' + version + '"'
]

# dependencies
thread_dep = dependency('threads', required: true)
libpcap_dep = dependency('libpcap', required: true)
project_deps = [
thread_dep,
libpcap_dep
]

#############################
## Code Compilation ##
#############################
subdir('src')

#############################
## Pkgconfig definition ##
#############################
pkgconfig = import('pkgconfig')
pkgconfig_install_dir = join_paths(get_option('libdir'), 'pkgconfig')
pkgconfig.generate(libnethogs,
requires: ['libpcap'],
version: version
)
2 changes: 2 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
option('enable-libnethogs', type: 'feature', value: 'enabled', description: 'Enable libnethogs library')
option('enable-nethogs-app', type: 'feature', value: 'enabled', description: 'Enable nethogs application')
67 changes: 67 additions & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#
# See COPYING for more information about licensing
#

sources = [
files([
'connection.cpp',
'conninode.cpp',
'decpcap.c',
'devices.cpp',
'inode2prog.cpp',
'packet.cpp',
'process.cpp',
])
]

# --- Executable Compilation ---

if get_option('enable-nethogs-app').enabled()
app_sources = [
files([
'main.cpp',
'cui.cpp',
])
]

cursespp_dep = dependency('ncurses++', required: true)
curses_dep = dependency('ncurses', required: true)

executable('nethogs',
[app_sources + sources],
include_directories: [projectinc],
cpp_args: c_args,
c_args: c_args,
install: true,
dependencies : [project_deps, cursespp_dep, curses_dep]
)
endif

# --- Library Compilation ---

if get_option('enable-libnethogs').enabled()
lib_sources = [
files([
'libnethogs.cpp',
])
]

libnethogs = shared_library('libnethogs' ,
sources + lib_sources,
cpp_args: c_args,
c_args: c_args,
install: true,
soversion: meson.project_version(),
include_directories: [projectinc],
dependencies: [project_deps]
)

libnethogs_dep = declare_dependency(link_with: libnethogs)

# --- Header Installation ---

lib_headers = [
files('libnethogs.h'),
]
install_headers(lib_headers, subdir : 'libnethogs')
endif