@@ -66,26 +66,37 @@ namespace
66
66
QStringList includes;
67
67
includes << QString (" ." );
68
68
69
- #if defined(Q_OS_WIN32)
70
- const char *path_splitter = " ;" ;
71
- #else
72
- const char *path_splitter = " :" ;
73
- #endif
69
+ QChar pathSplitter = QDir::listSeparator ();
74
70
75
- // Environment INCLUDE
76
- QString includePath = getenv (" INCLUDE " );
71
+ // Environment PYTHONQT_INCLUDE
72
+ QString includePath = getenv (" PYTHONQT_INCLUDE " );
77
73
if (!includePath.isEmpty ())
78
- includes += includePath.split (path_splitter );
74
+ includes += includePath.split (pathSplitter, Qt::SkipEmptyParts );
79
75
80
76
// Includes from the command line
81
77
if (!commandLineIncludes.isEmpty ())
82
- includes += commandLineIncludes.split (path_splitter);
78
+ includes += commandLineIncludes.split (pathSplitter, Qt::SkipEmptyParts);
79
+ for (auto it = includes.begin (); it != includes.end ();)
80
+ {
81
+ if (!QDir (*it).exists ())
82
+ {
83
+ qWarning (" Include path %s does not exist, ignoring it." , it->toUtf8 ().constData ());
84
+ it = includes.erase (it);
85
+ }
86
+ else
87
+ {
88
+ ++it;
89
+ }
90
+ }
83
91
84
92
// Include Qt
85
- QString qtdir = getenv (" QTDIR" );
86
- if (qtdir.isEmpty ()) {
93
+ QString qtdir = getenv (" QTDIR" );
94
+ if (qtdir.isEmpty () || !QDir (qtdir).exists (qtdir))
95
+ {
96
+ QString reason = " The QTDIR environment variable " + qtdir.isEmpty () ?
97
+ " is not set. " : " points to a non-existing directory. " ;
87
98
#if defined(Q_OS_MAC)
88
- qWarning (" QTDIR environment variable not set. Assuming standard binary install using frameworks." );
99
+ qWarning ((reason + " Assuming standard binary install using frameworks." ). toUtf8 (). constData () );
89
100
QString frameworkDir = " /Library/Frameworks" ;
90
101
includes << (frameworkDir + " /QtXml.framework/Headers" );
91
102
includes << (frameworkDir + " /QtNetwork.framework/Headers" );
@@ -94,9 +105,11 @@ namespace
94
105
includes << (frameworkDir + " /QtOpenGL.framework/Headers" );
95
106
includes << frameworkDir;
96
107
#else
97
- qWarning (" QTDIR environment variable not set. This may cause problems with finding the necessary include files." );
108
+ qWarning ((reason + " This may cause problems with finding the necessary include files." ). toUtf8 (). constData () );
98
109
#endif
99
- } else {
110
+ }
111
+ else
112
+ {
100
113
std::cout << " -------------------------------------------------------------" << std::endl;
101
114
std::cout << " Using QT at: " << qtdir.toLocal8Bit ().constData () << std::endl;
102
115
std::cout << " -------------------------------------------------------------" << std::endl;
@@ -353,11 +366,7 @@ int main(int argc, char *argv[])
353
366
354
367
355
368
void displayHelp (GeneratorSet* generatorSet) {
356
- #if defined(Q_OS_WIN32)
357
- char path_splitter = ' ;' ;
358
- #else
359
- char path_splitter = ' :' ;
360
- #endif
369
+ const auto path_splitter = QDir::listSeparator ().toLatin1 ();
361
370
printf (" Usage:\n generator [options] header-file typesystem-file\n\n " );
362
371
printf (" Available options:\n\n " );
363
372
printf (" General:\n " );
0 commit comments