Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/woboq/moc-ng
A reimplementation of Qt's moc using libclang. Contains both a drop-in remplacement, and a plugin for the clang compiler.
https://github.com/woboq/moc-ng
Last synced: about 1 hour ago
JSON representation
A reimplementation of Qt's moc using libclang. Contains both a drop-in remplacement, and a plugin for the clang compiler.
- Host: GitHub
- URL: https://github.com/woboq/moc-ng
- Owner: woboq
- License: gpl-3.0
- Created: 2013-05-15T13:29:21.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2022-08-19T15:51:33.000Z (about 2 years ago)
- Last Synced: 2024-08-04T00:03:38.126Z (3 months ago)
- Language: C++
- Homepage: https://woboq.com/blog/moc-with-clang.html
- Size: 271 KB
- Stars: 204
- Watchers: 24
- Forks: 24
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: COPYING
Awesome Lists containing this project
- awesome-qt - moc-ng - ng) - Alternative implementation of `moc` that's binary-compatible with Qt's version. (Tools / Third-Party Tools)
README
# moc-ng: a replacement for Qt's moc that is using clang libraries
This is really two projects:
* A plugin for clang which removes the needs of running moc
if your code is compiled with this plugin.* A replacement for moc that aim to be compatible with qt's moc,
but uses the clang libraries for the parsing step.Read the blog post: https://woboq.com/blog/moc-with-clang.html
[![Build Status](https://travis-ci.org/woboq/moc-ng.svg?branch=master)](https://travis-ci.org/woboq/moc-ng)
## Browse the source code online
https://code.woboq.org/mocng/src/## Compile
You need llvm and clang (>= 3.4).
Then run cmake and make (adapt your paths)cmake . -DCMAKE_CXX_COMPILER=/opt/llvm/bin/clang++ -DLLVM_CONFIG_EXECUTABLE=/opt/llvm/bin/llvm-config
make## Use
* As a binary: replace the moc provided by Qt by the one which is in src/moc
* As a clang plugin: Tell your build system not to run moc, and add this to the CXXFLAGS
-Xclang -load -Xclang /path/to/src/libmocng_plugin.so -Xclang -add-plugin -Xclang moc## Differences with upstream moc
This version of moc has nice additional support compared to upstream moc:
* Template support: You can have templated QObject
* Automatically register all types using qRegisterMetaType
* Supports trailing return type, auto return types for signals and slot and decltype in the
return type or parameter types.
* Support for nested classes.Not supported:
* OSX Framework options (-F)## Problems?
Make sure that the Qt include paths (and other include paths) are correctly passed to moc via the -I option
Report bugs on github: https://github.com/woboq/moc-ng/issues
## Tests
Replace the moc binary in the builddir (qtbase/bin/moc) and run the Qt tests.
Expecially the tst_moc and the tests for corelib/kernel.
The tests that are known to fail are worked around in "workaroundtests.cpp".
Tests for features not supported by normal Qt (such as templates) are found in
the tests subdirectory.
Check the README in the tests subdirectory for the moc-ng specific tests