diff --git a/generator/main.cpp b/generator/main.cpp index 621542f52..b9d12af99 100644 --- a/generator/main.cpp +++ b/generator/main.cpp @@ -217,7 +217,20 @@ namespace QRegularExpression re("#define\\s+QTCORE_VERSION\\s+0x([0-9a-f]+)", QRegularExpression::CaseInsensitiveOption); for (const QString &includeDir: getIncludeDirectories(commandLineIncludes)) { - QFileInfo fi(QDir(includeDir), "qtcoreversion.h"); + std::list candiate_paths; + candiate_paths.emplace_back("qtcoreversion.h"); + candiate_paths.emplace_back("QtCore/qtcoreversion.h"); + candiate_paths.emplace_back("QtCore.framework/Headers/qtcoreversion.h"); + QFileInfo fi(QDir(includeDir), QString("qtcoreversion.h")); + for (const std::string &candidate : candiate_paths) + { + QFileInfo candidate_fi(QDir(includeDir), candidate.c_str()); + if (candidate_fi.exists() && candidate_fi.isFile()) + { + fi = candidate_fi; + break; + } + } if (fi.exists()) { QString filePath = fi.absoluteFilePath(); diff --git a/generator/simplecpp/simplecpp.cpp b/generator/simplecpp/simplecpp.cpp index ee8f7f7cd..b7c0ce711 100644 --- a/generator/simplecpp/simplecpp.cpp +++ b/generator/simplecpp/simplecpp.cpp @@ -3116,6 +3116,22 @@ static std::string getIncludePathFileName(const std::string &includePath, const return path + header; } +#ifdef __APPLE__ +static std::string get_apple_framework_relative_path(const std::string& header) +{ + std::string appleFrameworkHeader = {header}; + // try the Framework path on Mac, if there is a path in front + // ### what about escaped slashes? + size_t slashPos = appleFrameworkHeader.find('/'); + if (slashPos != std::string::npos) + { + constexpr auto framework_separator{ ".framework/Headers" }; + appleFrameworkHeader.insert(slashPos, framework_separator); + } + return appleFrameworkHeader; +} +#endif // __APPLE__ + static std::string openHeaderIncludePath(std::ifstream &f, const simplecpp::DUI &dui, const std::string &header) { for (std::list::const_iterator it = dui.includePaths.begin(); it != dui.includePaths.end(); ++it) { @@ -3123,6 +3139,17 @@ static std::string openHeaderIncludePath(std::ifstream &f, const simplecpp::DUI if (!simplePath.empty()) return simplePath; } +#ifdef __APPLE__ + std::string appleFrameworkHeader = get_apple_framework_relative_path(header); + if (appleFrameworkHeader != header) + { + for (std::list::const_iterator it = dui.includePaths.begin(); it != dui.includePaths.end(); ++it) { + std::string simplePath = openHeader(f, getIncludePathFileName(*it, appleFrameworkHeader)); + if (!simplePath.empty()) + return simplePath; + } + } +#endif // __APPLE__ return ""; } diff --git a/generator/simplecpp/simplecpp.h b/generator/simplecpp/simplecpp.h index f5c69593c..df2e78180 100644 --- a/generator/simplecpp/simplecpp.h +++ b/generator/simplecpp/simplecpp.h @@ -39,6 +39,9 @@ #endif namespace simplecpp { + + std::string get_apple_framework_relative_path(const std::string& header); + /** C code standard */ enum cstd_t { CUnknown=-1, C89, C99, C11, C17, C23 };