@@ -66,26 +66,37 @@ namespace
6666 QStringList includes;
6767 includes << QString (" ." );
6868
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 ();
7470
75- // Environment INCLUDE
76- QString includePath = getenv (" INCLUDE " );
71+ // Environment PYTHONQT_INCLUDE
72+ QString includePath = getenv (" PYTHONQT_INCLUDE " );
7773 if (!includePath.isEmpty ())
78- includes += includePath.split (path_splitter );
74+ includes += includePath.split (pathSplitter, Qt::SkipEmptyParts );
7975
8076 // Includes from the command line
8177 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+ }
8391
8492 // 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. " ;
8798#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 () );
89100 QString frameworkDir = " /Library/Frameworks" ;
90101 includes << (frameworkDir + " /QtXml.framework/Headers" );
91102 includes << (frameworkDir + " /QtNetwork.framework/Headers" );
@@ -94,9 +105,11 @@ namespace
94105 includes << (frameworkDir + " /QtOpenGL.framework/Headers" );
95106 includes << frameworkDir;
96107#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 () );
98109#endif
99- } else {
110+ }
111+ else
112+ {
100113 std::cout << " -------------------------------------------------------------" << std::endl;
101114 std::cout << " Using QT at: " << qtdir.toLocal8Bit ().constData () << std::endl;
102115 std::cout << " -------------------------------------------------------------" << std::endl;
@@ -353,11 +366,7 @@ int main(int argc, char *argv[])
353366
354367
355368void 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 ();
361370 printf (" Usage:\n generator [options] header-file typesystem-file\n\n " );
362371 printf (" Available options:\n\n " );
363372 printf (" General:\n " );
0 commit comments