Skip to content

Integrated generation of Qt Meta-Object code using MOC in GN build system

License

Notifications You must be signed in to change notification settings

davidc604/qt_moc_generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Qt MOC Generator

Integration of generation of Qt Meta-Object code using the Meta-Object Compiler (moc) in GN build system.

Introduction

This repo contains a GN defintion file (qt_generator.gni)and the generation python script (qt_moc_generator.py).

Requirements

Usage

Import the .gni file in the BUILD.gn where you need to generate Qt meta-object sources.

import("//project-root/{dir}/qt_generator.gni")

Create a built source_set, for example:

qt_moc_generator("qt_sources") {
    qt_moc_generator_path = rebase_path("qt/qt_moc_generator.py", ".")
    
    sources = [
        "src/qt_header1.h",
        "src/qt_header2.h",
    ]
    include_dirs = [
        "/usr/include/qt5",
        "/usr/include/qt5/QtCore",
    ]
    moc_out_dir = "qt/generated_moc"
}

Then in your target library or executable, add the generated as part of the dependencies,

executable("awesome_exec") {
    sources = [
        "src/source1.cc",
        "src/source2.cc",
        "src/source3.cc",
        "src/main.cc"
    ]
    deps = [
        "//third_party/deps1",
        "//third_party/deps2",
        ":qt_sources"
    ]
    cflags = [
        "-Wno-error"
    ]
    libs = [
        "Qt5Core",
    ]
}

Afterwards, simply run gn gen <folder> and build, the scripts will automatically generate the required meta-object sources and object files and include in your project/library.

About

Integrated generation of Qt Meta-Object code using MOC in GN build system

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages