diff options
-rw-r--r-- | sources/shiboken2/ApiExtractor/CMakeLists.txt | 2 | ||||
-rw-r--r-- | sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp | 24 |
2 files changed, 21 insertions, 5 deletions
diff --git a/sources/shiboken2/ApiExtractor/CMakeLists.txt b/sources/shiboken2/ApiExtractor/CMakeLists.txt index 760cc6985..c55dba973 100644 --- a/sources/shiboken2/ApiExtractor/CMakeLists.txt +++ b/sources/shiboken2/ApiExtractor/CMakeLists.txt @@ -63,6 +63,8 @@ if (NOT DISABLE_DOCSTRINGS) endif() endif() +target_compile_definitions(apiextractor PRIVATE CMAKE_CXX_COMPILER="${CMAKE_CXX_COMPILER}") + set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE PATH "The subdirectory relative to the install prefix where libraries will be installed (default is /lib${LIB_SUFFIX})" FORCE) if (BUILD_TESTS) diff --git a/sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp b/sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp index d3d5c8da8..3196c824e 100644 --- a/sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp +++ b/sources/shiboken2/ApiExtractor/clangparser/compilersupport.cpp @@ -189,7 +189,7 @@ static LinuxDistribution linuxDistribution() const QString &productType = QSysInfo::productType(); if (productType == QLatin1String("rhel")) return LinuxDistribution::RedHat; - if (productType == QLatin1String("centos")) + if (productType.compare(QLatin1String("centos"), Qt::CaseInsensitive) == 0) return LinuxDistribution::CentOs; return LinuxDistribution::Other; } @@ -207,7 +207,7 @@ static inline bool needsGppInternalHeaders() switch (distro) { case LinuxDistribution::RedHat: case LinuxDistribution::CentOs: - return checkProductVersion(QVersionNumber(7), QVersionNumber(8)); + return checkProductVersion(QVersionNumber(6, 10), QVersionNumber(8)); case LinuxDistribution::Other: break; } @@ -288,6 +288,18 @@ static QString findClangBuiltInIncludesDir() } #endif // NEED_CLANG_BUILTIN_INCLUDES +#if defined(Q_CC_CLANG) || defined(Q_CC_GNU) +static QString compilerFromCMake(const QString &defaultCompiler) +{ +# ifdef CMAKE_CXX_COMPILER + Q_UNUSED(defaultCompiler) + return QString::fromLocal8Bit(CMAKE_CXX_COMPILER); +#else + return defaultCompiler; +# endif +} +#endif // Q_CC_CLANG, Q_CC_GNU + // Returns clang options needed for emulating the host compiler QByteArrayList emulatedCompilerOptions() { @@ -297,7 +309,7 @@ QByteArrayList emulatedCompilerOptions() result.append(QByteArrayLiteral("-fms-compatibility-version=19")); result.append(QByteArrayLiteral("-Wno-microsoft-enum-value")); #elif defined(Q_CC_CLANG) - HeaderPaths headerPaths = gppInternalIncludePaths(QStringLiteral("clang++")); + HeaderPaths headerPaths = gppInternalIncludePaths(compilerFromCMake(QStringLiteral("clang++"))); result.append(noStandardIncludeOption()); #elif defined(Q_CC_GNU) HeaderPaths headerPaths; @@ -322,10 +334,12 @@ QByteArrayList emulatedCompilerOptions() // A fix for this has been added to Clang 5.0, so, the code can be removed // once Clang 5.0 is the minimum version. if (needsGppInternalHeaders()) { - const HeaderPaths gppPaths = gppInternalIncludePaths(QStringLiteral("g++")); + const HeaderPaths gppPaths = gppInternalIncludePaths(compilerFromCMake(QStringLiteral("g++"))); for (const HeaderPath &h : gppPaths) { - if (h.path.contains("c++")) + if (h.path.contains("c++") + || h.path.contains("sysroot")) { // centOS headerPaths.append(h); + } } } #else |