project(
    'dimmSpdReader',
    'cpp',
    default_options: [
        'warning_level=3',
        'werror=true',
        'cpp_std=c++20'
    ],
    license: 'Apache-2.0',
    version: '0.1',
    meson_version: '>=0.58.0',
)

add_project_arguments(
    '-Wno-psabi',
    '-Wuninitialized',
    '-DBOOST_SYSTEM_NO_DEPRECATED',
    '-DBOOST_ASIO_NO_DEPRECATED',
    '-DBOOST_ERROR_CODE_HEADER_ONLY',
    '-DBOOST_NO_RTTI',
    '-DBOOST_NO_TYPEID',
    '-DBOOST_ALL_NO_LIB',
    '-DBOOST_ASIO_DISABLE_THREADS',
    '-DBOOST_ALLOW_DEPRECATED_HEADERS',
    '-DBOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT',
    language: 'cpp',
)

cpp = meson.get_compiler('cpp')

gpiodcxx = dependency('libgpiodcxx',
    default_options: ['bindings=cxx'],
)

sdbusplus = dependency('sdbusplus', required : true, include_type: 'system')
if not sdbusplus.found()
  sdbusplus_proj = subproject('sdbusplus', required: true)
  sdbusplus = sdbusplus_proj.get_variable('sdbusplus_dep')
  sdbusplus = sdbusplus.as_system('system')
endif

phosphor_logging_dep = dependency('phosphor-logging')

if cpp.has_header('nlohmann/json.hpp')
    nlohmann_json = declare_dependency()
else
    nlohmann_json = dependency('nlohmann_json')
endif

systemd = dependency('systemd')

boost = dependency('boost',version : '>=1.79.0', required : false, include_type: 'system')
if not boost.found()
  subproject('boost', required: false)
  boost_inc = include_directories('subprojects/boost_1_79_0/', is_system:true)
  boost  = declare_dependency(include_directories : boost_inc)
  boost = boost.as_system('system')
endif

default_deps = [
    boost,
    nlohmann_json,
    phosphor_logging_dep,
    sdbusplus,
    gpiodcxx,
]

executable(
        'dimmspdreader',
        'dimmSpdReader.cpp',
        'dimmSpdReaderMain.cpp',
        dependencies: [
            default_deps,
        ],
        install: true,
)
