Skip to content

Commit ef43d86

Browse files
committed
Compute private Qt header paths with preprocessor.
Updates #39.
1 parent 0abc10c commit ef43d86

File tree

6 files changed

+77
-11
lines changed

6 files changed

+77
-11
lines changed

README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ Something along these lines should be effective:
8787

8888
$ export PKG_CONFIG_PATH=`brew --prefix qt5`/lib/pkgconfig
8989
$ QT5VERSION=`pkg-config --modversion Qt5Core`
90-
$ # For "private/qmetaobject_p.h" inclusion
91-
$ export CGO_CPPFLAGS=-I`brew --prefix qt5`/include/QtCore/$QT5VERSION/QtCore
9290
$ CXX=g++-4.8 go get gopkg.in/qml.v0
9391

9492
For Mac OS X Mavericks you may need to use `brew install qt5 --HEAD` and check that QT5VERSION
@@ -106,7 +104,7 @@ On Windows you'll need the following:
106104

107105
Then, assuming Qt was installed under `C:\Qt5.1.1\`, set up the following environment variables in the respective configuration:
108106

109-
CPATH += C:\Qt5.1.1\5.1.1\mingw48_32\include;C:\Qt5.1.1\5.1.1\mingw48_32\include\QtCore\5.1.1\QtCore
107+
CPATH += C:\Qt5.1.1\5.1.1\mingw48_32\include
110108
LIBRARY_PATH += C:\Qt5.1.1\5.1.1\mingw48_32\lib
111109
PATH += C:\Qt5.1.1\5.1.1\mingw48_32\bin
112110

bridge.go

-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
package qml
22

33
// #cgo CPPFLAGS: -I./cpp
4-
// #cgo CPPFLAGS: -I/usr/include/qt5/QtCore/5.0.1/QtCore
5-
// #cgo CPPFLAGS: -I/usr/include/qt5/QtCore/5.0.2/QtCore
6-
// #cgo CPPFLAGS: -I/usr/include/qt5/QtCore/5.1.1/QtCore
7-
// #cgo CPPFLAGS: -I/usr/include/qt5/QtCore/5.2.0/QtCore
8-
// #cgo CPPFLAGS: -I/usr/include/qt5/QtCore/5.2.1/QtCore
9-
// #cgo CPPFLAGS: -I/usr/include/qt/QtCore/5.1.1/QtCore
10-
// #cgo CPPFLAGS: -I/usr/include/qt/QtCore/5.2.0/QtCore
11-
// #cgo CPPFLAGS: -I/usr/include/qt/QtCore/5.2.1/QtCore
124
// #cgo CXXFLAGS: -std=c++0x -pedantic-errors -Wall -fno-strict-aliasing
135
// #cgo LDFLAGS: -lstdc++
146
// #cgo pkg-config: Qt5Core Qt5Widgets Qt5Quick

cpp/private/qmetaobject_p.h

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#include "private/qtheader.h"
2+
#include QT_PRIVATE_HEADER(QtCore,qmetaobject_p.h)

cpp/private/qmetaobjectbuilder_p.h

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#include "private/qtheader.h"
2+
#include QT_PRIVATE_HEADER(QtCore,qmetaobjectbuilder_p.h)

cpp/private/qobject_p.h

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#include "private/qtheader.h"
2+
#include QT_PRIVATE_HEADER(QtCore,qobject_p.h)

cpp/private/qtheader.h

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#ifndef QTPRIVATE_H
2+
#define QTPRIVATE_H
3+
4+
#include <QtCore/qglobal.h>
5+
6+
#define QT_MAJOR_ (QT_VERSION>>16)
7+
#define QT_MINOR_ (QT_VERSION>>8&0xFF)
8+
#define QT_MICRO_ (QT_VERSION&0xFF)
9+
10+
#if QT_MAJOR_ == 5
11+
#define QT_MAJOR 5
12+
#else
13+
#error Unupported Qt major version. Please report.
14+
#endif
15+
16+
#if QT_MINOR_ == 0
17+
#define QT_MINOR 0
18+
#elif QT_MINOR_ == 1
19+
#define QT_MINOR 1
20+
#elif QT_MINOR_ == 2
21+
#define QT_MINOR 2
22+
#elif QT_MINOR_ == 3
23+
#define QT_MINOR 3
24+
#elif QT_MINOR_ == 4
25+
#define QT_MINOR 4
26+
#elif QT_MINOR_ == 5
27+
#define QT_MINOR 5
28+
#elif QT_MINOR_ == 6
29+
#define QT_MINOR 6
30+
#elif QT_MINOR_ == 7
31+
#define QT_MINOR 7
32+
#elif QT_MINOR_ == 8
33+
#define QT_MINOR 8
34+
#elif QT_MINOR_ == 9
35+
#define QT_MINOR 9
36+
#elif QT_MINOR_ == 10
37+
#define QT_MINOR 10
38+
#else
39+
#error Unupported Qt minor version. Please report.
40+
#endif
41+
42+
#if QT_MICRO_ == 0
43+
#define QT_MICRO 0
44+
#elif QT_MICRO_ == 1
45+
#define QT_MICRO 1
46+
#elif QT_MICRO_ == 2
47+
#define QT_MICRO 2
48+
#elif QT_MICRO_ == 3
49+
#define QT_MICRO 3
50+
#elif QT_MICRO_ == 4
51+
#define QT_MICRO 4
52+
#elif QT_MICRO_ == 5
53+
#define QT_MICRO 5
54+
#elif QT_MICRO_ == 6
55+
#define QT_MICRO 6
56+
#elif QT_MICRO_ == 7
57+
#define QT_MICRO 7
58+
#elif QT_MICRO_ == 8
59+
#define QT_MICRO 8
60+
#elif QT_MICRO_ == 9
61+
#define QT_MICRO 9
62+
#elif QT_MICRO_ == 10
63+
#define QT_MICRO 10
64+
#else
65+
#error Unupported Qt micro version. Please report.
66+
#endif
67+
68+
#define QT_PRIVATE_HEADER(dir,file) <dir/QT_MAJOR.QT_MINOR.QT_MICRO/dir/private/file>
69+
70+
#endif // QTPRIVATE_H

0 commit comments

Comments
 (0)