CuarzoSoftware / Louvre

C++ library for building Wayland compositors.
MIT License
506 stars 14 forks source link

Compile louvre-views as separated project. #9

Closed ahmadraniri1994 closed 9 months ago

ahmadraniri1994 commented 9 months ago

Hello, I'm interested on louvre-views (examples). How do I compile it without rebuilding the whole Louvre library. Is there a usable Makefile or meson.build ? Thanks.

ehopperdietzel commented 9 months ago

Hi, yes simply duplicate the louvre-views directory and replace its meson.build file with the one supplied here. Please note that the example extensively relies on assets located in /usr/etc/Louvre/assets, particularly within the Global.cpp file. If you opt for an alternative path, be sure to manually update those accordingly.

meson.build

project(
    'Project Name',
    'c','cpp',
    version : '0.1.0',
    meson_version: '>= 0.56.0',
    default_options: [
        'warning_level=2',
        'cpp_std=c++11',
    ]
)

ASSETS_PATH = '/usr/etc/Louvre/assets'

cpp = meson.get_compiler('cpp')

include_directories = [
    '/usr/include/pixman-1',
    '/usr/include/drm',
    '/usr/include/libdrm',
    '/usr/include/Louvre',
    '/usr/include/freetype2'
]

include_directories_filtered = []

# Exclude non-existent directories to prevent meson from throwing errors
foreach d : include_directories
    if run_command('[', '-d', d, ']', check : false).returncode() == 0
        include_directories_filtered += [include_directories(d)]
    endif
endforeach

louvre_dep          = cpp.find_library('Louvre')
wayland_server_dep  = cpp.find_library('wayland-server')
input_dep           = cpp.find_library('input')
icuuc_dep           = cpp.find_library('icuuc')
fontconfig_dep      = cpp.find_library('fontconfig')
freetype_dep        = cpp.find_library('freetype')

sources = run_command('find', './src', '-type', 'f', '-name', '*[.c,.cpp,.h,.hpp]', check : false).stdout().strip().split('\n')

executable(
    'louvre-views',
    sources,
    include_directories: include_directories_filtered,
    dependencies : [
        louvre_dep,
        wayland_server_dep,
        input_dep,
        fontconfig_dep,
        freetype_dep,
        icuuc_dep
    ],
    install : true)

assets = run_command('find', './assets', '-type', 'f', '-name', '*[.png, .list]', check : false).stdout().strip().split('\n')

install_data(
    assets,
    install_dir: ASSETS_PATH
)
ahmadraniri1994 commented 9 months ago

Great. I'll try that.