Waybar/meson.build

254 lines
7.8 KiB
Meson
Raw Normal View History

2018-08-10 14:37:03 +00:00
project(
'waybar', 'cpp', 'c',
version: '4.1.0',
2018-08-10 14:37:03 +00:00
license: 'MIT',
meson_version: '>= 1.3.0',
2018-08-30 09:30:20 +00:00
default_options : [
'cpp_std=c++23',
2018-11-08 08:57:24 +00:00
'buildtype=release',
'default_library=static'
2018-08-30 09:30:20 +00:00
],
2018-08-10 14:37:03 +00:00
)
2018-08-08 21:54:58 +00:00
compiler = meson.get_compiler('cpp')
2018-12-26 10:13:36 +00:00
cpp_args = []
2018-08-19 11:41:22 +00:00
cpp_link_args = []
2018-08-08 21:54:58 +00:00
if get_option('libcxx')
2018-08-08 21:54:58 +00:00
cpp_args += ['-stdlib=libc++']
cpp_link_args += ['-stdlib=libc++', '-lc++abi']
endif
2018-08-08 21:54:58 +00:00
if compiler.has_link_argument('-lc++fs')
cpp_link_args += ['-lc++fs']
elif compiler.has_link_argument('-lstdc++fs')
2018-08-08 21:54:58 +00:00
cpp_link_args += ['-lstdc++fs']
endif
2020-04-05 14:12:25 +00:00
git = find_program('git', native: true, required: false)
2018-12-26 10:13:36 +00:00
if not git.found()
add_project_arguments('-DVERSION="@0@"'.format(meson.project_version()), language: 'cpp')
else
2020-05-24 17:14:27 +00:00
git_path = run_command([git.path(), 'rev-parse', '--show-toplevel']).stdout().strip()
if meson.source_root() == git_path
git_commit_hash = run_command([git.path(), 'describe', '--always', '--tags']).stdout().strip()
git_branch = run_command([git.path(), 'rev-parse', '--abbrev-ref', 'HEAD']).stdout().strip()
version = '"@0@ (branch \'@1@\')"'.format(git_commit_hash, git_branch)
2020-05-24 17:14:27 +00:00
add_project_arguments('-DVERSION=@0@'.format(version), language: 'cpp')
else
add_project_arguments('-DVERSION="@0@"'.format(meson.project_version()), language: 'cpp')
endif
2018-12-26 10:13:36 +00:00
endif
2018-11-08 08:57:24 +00:00
code = '''
#include <langinfo.h>
#include <locale.h>
int main(int argc, char** argv) {
locale_t locale = newlocale(LC_ALL, "en_US.UTF-8", nullptr);
char* str;
str = nl_langinfo_l(_NL_TIME_WEEK_1STDAY, locale);
str = nl_langinfo_l(_NL_TIME_FIRST_WEEKDAY, locale);
freelocale(locale);
return 0;
}
'''
if compiler.links(code, name : 'nl_langinfo with _NL_TIME_WEEK_1STDAY, _NL_TIME_FIRST_WEEKDAY')
add_project_arguments('-DHAVE_LANGINFO_1STDAY', language: 'cpp')
endif
2018-08-08 21:54:58 +00:00
add_global_arguments(cpp_args, language : 'cpp')
add_global_link_arguments(cpp_link_args, language : 'cpp')
is_linux = host_machine.system() == 'linux'
2019-08-09 10:40:33 +00:00
is_dragonfly = host_machine.system() == 'dragonfly'
is_freebsd = host_machine.system() == 'freebsd'
is_netbsd = host_machine.system() == 'netbsd'
is_openbsd = host_machine.system() == 'openbsd'
jsoncpp = dependency('jsoncpp', version : ['>=1.9.4'], fallback : ['jsoncpp', 'jsoncpp_dep'])
2018-08-08 21:54:58 +00:00
wayland_client = dependency('wayland-client')
wayland_cursor = dependency('wayland-cursor')
wayland_protos = dependency('wayland-protocols')
sigcpp = dependency('sigc++-3.0', version: ['>=3.4.0'])
gtkmm = dependency('gtkmm-4.0', version : ['>=4.12.0'])
giounix = dependency('gio-unix-2.0', version: ['>=2.76.4'])
spdlog = dependency('spdlog', version : ['>=1.10.0'], fallback : ['spdlog', 'spdlog_dep'], default_options : ['external_fmt=enabled'])
libudev = dependency('libudev', required: get_option('libudev'))
gtk_layer_shell = dependency('gtk4-layer-shell-0',
version : ['>=1.0.2'],
fallback : ['gtk4-layer-shell', 'gtk_layer_shell'],
default_options : ['introspection=false', 'vapi=false'])
cpp_lib_chrono = compiler.compute_int('__cpp_lib_chrono', prefix : '#include <chrono>')
have_chrono_timezones = cpp_lib_chrono >= 201611
if have_chrono_timezones
code = '''
#include <chrono>
using namespace std::chrono;
int main(int argc, char** argv) {
const time_zone* tz;
return 0;
}
'''
if not compiler.links(code)
have_chrono_timezones = false
endif
endif
if have_chrono_timezones
tz_dep = declare_dependency()
else
tz_dep = dependency('date',
required: false,
default_options : [ 'use_system_tzdb=true' ],
modules : [ 'date::date', 'date::date-tz' ],
fallback: [ 'date', 'tz_dep' ])
endif
2019-09-10 12:12:52 +00:00
prefix = get_option('prefix')
sysconfdir = get_option('sysconfdir')
conf_data = configuration_data()
2019-09-10 12:12:52 +00:00
conf_data.set('prefix', prefix)
add_project_arguments('-DSYSCONFDIR="/@0@"'.format(join_paths(prefix, sysconfdir)), language : 'cpp')
2018-08-20 15:20:02 +00:00
src_files = files(
'src/main.cpp',
'src/client.cpp',
'src/bar.cpp',
'src/config.cpp',
'src/util/portal.cpp',
'src/util/prepare_for_sleep.cpp',
'src/AModule.cpp',
'src/ALabel.cpp',
'src/factory.cpp',
'src/util/ustring_clen.cpp',
'src/group.cpp',
'src/ASlider.cpp',
'src/modules/load.cpp',
'src/modules/disk.cpp'
)
man_files = files(
'man/waybar-custom.5.scd',
'man/waybar-disk.5.scd',
'man/waybar-idle-inhibitor.5.scd',
'man/waybar-image.5.scd',
'man/waybar-states.5.scd',
'man/waybar-temperature.5.scd',
2018-08-20 15:20:02 +00:00
)
2018-08-08 21:54:58 +00:00
if have_chrono_timezones
add_project_arguments('-DHAVE_CHRONO_TIMEZONES', language: 'cpp')
src_files += files('src/modules/clock.cpp')
man_files += files('man/waybar-clock.5.scd')
elif tz_dep.found()
add_project_arguments('-DHAVE_LIBDATE', language: 'cpp')
src_files += files('src/modules/clock.cpp')
man_files += files('man/waybar-clock.5.scd')
else
src_files += files('src/modules/simpleclock.cpp')
man_files += files('man/waybar-clock.5.scd')
endif
if get_option('experimental')
add_project_arguments('-DUSE_EXPERIMENTAL', language: 'cpp')
endif
if libudev.found() and (is_linux or libepoll.found())
add_project_arguments('-DHAVE_LIBUDEV', language: 'cpp')
src_files += files(
'src/modules/backlight.cpp',
'src/modules/backlight_slider.cpp',
'src/util/backlight_backend.cpp',
)
man_files += files(
'man/waybar-backlight.5.scd',
'man/waybar-backlight-slider.5.scd',
)
endif
cava = dependency('cava',
version : '>=0.10.1',
required: get_option('cava'),
fallback : ['cava', 'cava_dep'],
not_found_message: 'cava is not found. Building waybar without cava')
if cava.found()
add_project_arguments('-DHAVE_LIBCAVA', language: 'cpp')
src_files += files('src/modules/cava.cpp')
man_files += files('man/waybar-cava.5.scd')
endif
inc_dirs = ['include']
if is_linux
add_project_arguments('-DHAVE_CPU_LINUX', language: 'cpp')
add_project_arguments('-DHAVE_MEMORY_LINUX', language: 'cpp')
src_files += files('src/modules/battery.cpp',
'src/modules/cpu.cpp',
'src/modules/cpu_frequency/common.cpp',
'src/modules/cpu_frequency/linux.cpp',
'src/modules/cpu_usage/common.cpp',
'src/modules/cpu_usage/linux.cpp',
'src/modules/memory/common.cpp',
'src/modules/memory/linux.cpp')
man_files += files('man/waybar-battery.5.scd',
'man/waybar-cpu.5.scd',
'man/waybar-memory.5.scd')
elif is_dragonfly or is_freebsd or is_netbsd or is_openbsd
add_project_arguments('-DHAVE_CPU_BSD', language: 'cpp')
add_project_arguments('-DHAVE_MEMORY_BSD', language: 'cpp')
src_files += files(
# 'src/modules/cffi.cpp',
'src/modules/cpu.cpp',
'src/modules/cpu_frequency/bsd.cpp',
'src/modules/cpu_frequency/common.cpp',
'src/modules/cpu_usage/bsd.cpp',
'src/modules/cpu_usage/common.cpp',
'src/modules/memory/bsd.cpp',
'src/modules/memory/common.cpp',
)
man_files += files(
# 'man/waybar-cffi.5.scd',
'man/waybar-cpu.5.scd',
'man/waybar-memory.5.scd'
)
if is_freebsd
src_files += files('src/modules/battery.cpp')
man_files += files('man/waybar-battery.5.scd')
endif
endif
2018-08-20 15:20:02 +00:00
subdir('protocol')
2018-08-16 12:29:41 +00:00
2018-08-08 21:54:58 +00:00
executable(
'waybar',
[src_files],
2018-08-08 21:54:58 +00:00
dependencies: [
gtk_layer_shell,
gtkmm,
giounix,
2018-08-08 21:54:58 +00:00
sigcpp,
libudev,
2018-08-08 21:54:58 +00:00
jsoncpp,
wayland_client,
2018-08-08 21:54:58 +00:00
wayland_cursor,
client_protos,
spdlog,
cava
2018-08-08 21:54:58 +00:00
],
include_directories: inc_dirs,
2018-08-08 21:54:58 +00:00
install: true,
)
2018-08-09 15:02:30 +00:00
install_data(
'./resources/config',
'./resources/style.css',
install_dir: sysconfdir + '/xdg/waybar'
2018-08-09 15:02:30 +00:00
)