Waybar/meson.build

191 lines
5.7 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('-lc++experimental')
cpp_link_args += ['-lc++experimental']
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
if not compiler.has_header('filesystem')
if compiler.has_header('experimental/filesystem')
add_project_arguments('-DFILESYSTEM_EXPERIMENTAL', language: 'cpp')
else
add_project_arguments('-DNO_FILESYSTEM', language: 'cpp')
warning('No filesystem header found, some modules may not work')
endif
2018-11-08 08:57:24 +00:00
endif
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'])
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'
)
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
inc_dirs = ['include']
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,
jsoncpp,
wayland_client,
2018-08-08 21:54:58 +00:00
wayland_cursor,
client_protos,
spdlog
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
)