New-Cli-Installer/meson.build

142 lines
4.1 KiB
Meson
Raw Normal View History

2021-11-26 02:34:58 +08:00
project('cachyos-installer', 'cpp',
version: '0.0.1',
license: 'GPLv3',
meson_version: '>=0.55.0',
default_options: ['cpp_std=c++20',
'buildtype=debugoptimized',
'warning_level=3',
2021-12-01 06:03:18 +08:00
'werror=true',
2021-11-26 02:34:58 +08:00
'b_ndebug=if-release'])
is_debug_build = get_option('buildtype').startswith('debug')
is_dev_environment = get_option('devenv')
2021-11-26 02:34:58 +08:00
cc = meson.get_compiler('cpp')
if cc.get_id() == 'clang'
2021-12-01 06:03:18 +08:00
specific_cc_flags = [
'-nostdlib++',
'-nodefaultlibs',
]
specific_link_flags = [
'-fuse-ld=lld',
]
add_global_arguments(cc.get_supported_arguments(specific_cc_flags), language : 'cpp')
add_global_link_arguments(cc.get_supported_link_arguments(specific_link_flags), language : 'cpp')
endif
2021-11-26 02:34:58 +08:00
if is_debug_build
add_global_arguments('-D_GLIBCXX_ASSERTIONS', language : 'cpp')
endif
if not is_dev_environment
add_global_arguments('-DNDEVENV', language : 'cpp')
endif
2021-11-26 02:34:58 +08:00
# Common dependencies
spdlog = dependency('spdlog', version : ['>=1.9.2'])
2021-11-26 02:34:58 +08:00
fmt = dependency('fmt', version : ['>=8.0.0'], fallback : ['fmt', 'fmt_dep'])
ftxui = dependency('ftxui', modules : ['ftxui::screen', 'ftxui::dom', 'ftxui::component'], fallback : ['ftxui', 'ftxui_dep'])
2021-11-26 02:34:58 +08:00
nlohmann_json = dependency('nlohmann_json', version : ['>=3.10.4'], fallback : ['nlohmann_json', 'nlohmann_json_dep'])
cpr = dependency('cpr', version : ['>=1.7.0'], fallback : ['cpr', 'cpr_dep'])
2021-12-02 15:57:13 +08:00
libnm = dependency('libnm', version : ['>=1.10.6'])
glibmm = dependency('glibmm-2.4', version : ['>=2.56.0'])
2021-11-26 02:34:58 +08:00
src_files = files(
2021-12-03 07:10:05 +08:00
'src/view.hpp',
2021-11-26 02:34:58 +08:00
'src/definitions.hpp',
2021-12-03 07:10:05 +08:00
'src/screen_service.hpp', 'src/screen_service.cpp',
'src/config.cpp', 'src/config.hpp',
2021-11-26 02:34:58 +08:00
'src/utils.cpp', 'src/utils.hpp',
'src/widgets.cpp', 'src/widgets.hpp',
2021-12-27 07:04:03 +08:00
'src/follow_process_log.cpp', 'src/follow_process_log.hpp',
2021-11-29 02:36:27 +08:00
'src/tui.cpp', 'src/tui.hpp',
2021-11-26 02:34:58 +08:00
'src/main.cpp',
)
possible_cc_flags = [
2021-12-01 06:03:18 +08:00
'-Wshadow',
2021-11-26 02:34:58 +08:00
2021-12-01 06:03:18 +08:00
'-Wnon-virtual-dtor',
2021-11-26 02:34:58 +08:00
2021-12-01 06:03:18 +08:00
'-Wcast-align',
'-Wunused',
'-Woverloaded-virtual',
2021-11-26 02:34:58 +08:00
2021-12-01 06:03:18 +08:00
'-Wpedantic', # non-standard C++
'-Wconversion', # type conversion that may lose data
'-Wnull-dereference',
'-Wdouble-promotion', # float to double
2021-11-26 02:34:58 +08:00
2021-12-01 06:03:18 +08:00
'-Wformat=2',
2021-12-01 20:42:20 +08:00
'-Wimplicit-fallthrough', # fallthrough without an explicit annotation
2021-11-26 02:34:58 +08:00
]
if cc.get_id() == 'gcc'
2021-12-01 06:03:18 +08:00
possible_cc_flags += [
'-Wmisleading-indentation',
2021-11-26 02:34:58 +08:00
2021-12-01 06:03:18 +08:00
'-Wduplicated-cond',
'-Wduplicated-branches',
'-Wlogical-op',
2021-12-01 20:42:20 +08:00
'-Wuseless-cast',
2021-12-01 06:03:18 +08:00
]
2021-11-26 02:34:58 +08:00
endif
if not is_debug_build
2021-11-26 02:34:58 +08:00
if cc.get_id() == 'gcc'
possible_cc_flags += [
'-flto',
'-fwhole-program',
]
else
possible_cc_flags += [
'-flto=thin',
]
endif
possible_cc_flags += ['-fdata-sections', '-ffunction-sections']
possible_link_flags = ['-Wl,--gc-sections']
add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language : 'cpp')
2021-11-26 02:34:58 +08:00
endif
add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language : 'cpp')
executable(
'cachyos-installer',
src_files,
2021-12-19 18:42:46 +08:00
dependencies: [fmt, spdlog, ftxui, cpr, glibmm],
2021-11-26 02:34:58 +08:00
include_directories: [include_directories('src')],
install: true)
2021-12-05 08:15:34 +08:00
executable(
'test-exec-interactive',
files('src/config.cpp', 'src/tui.cpp', 'src/utils.cpp', 'src/main_test.cpp'),
2021-12-19 18:42:46 +08:00
dependencies: [fmt, spdlog, ftxui, cpr, glibmm],
2021-12-05 08:15:34 +08:00
include_directories: [include_directories('src')],
install: false)
2021-12-27 02:42:19 +08:00
executable(
'test-process-tailing',
2021-12-27 07:04:03 +08:00
files('src/config.cpp', 'src/widgets.cpp', 'src/tui.cpp', 'src/utils.cpp', 'src/follow_process_log.cpp','src/test_proccess_tailing.cpp'),
2021-12-27 02:42:19 +08:00
dependencies: [fmt, spdlog, ftxui, cpr, glibmm],
include_directories: [include_directories('src')],
install: false)
2021-11-26 02:34:58 +08:00
summary(
{
'Build type': get_option('buildtype'),
},
bool_yn: true
)
clangtidy = find_program('clang-tidy', required: false)
if clangtidy.found()
run_target(
'tidy',
command: [
clangtidy,
'-checks=*,-fuchsia-default-arguments',
'-p', meson.build_root()
] + src_files)
endif