From f1e89d34ff9af34ebc698904c7f13875f309de10 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 22 Mar 2024 17:51:12 +0100 Subject: shiboken6: Handle CMAKE_CXX_COMPILER in non-standard locations CMAKE_CXX_COMPILER on the build machine may point to a non-standard location. Add a patch search to handle this. Task-number: PYSIDE-2648 Pick-to: 6.6 Change-Id: I049aa1a9c5ac086d381912be1af5f166f1e54608 Reviewed-by: Shyamnath Premnadh Reviewed-by: Qt CI Bot (cherry picked from commit 6785dc5fbfb99d08f32c6f28f3d5470cd7d5cec2) Reviewed-by: Qt Cherry-pick Bot --- .../ApiExtractor/clangparser/compilersupport.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp b/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp index 1b3c2d7d8..1f40f0a82 100644 --- a/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp +++ b/sources/shiboken6/ApiExtractor/clangparser/compilersupport.cpp @@ -323,9 +323,22 @@ static QString compilerFromCMake(const QString &defaultCompiler) // Exclude macOS since cmakeCompiler returns the full path instead of the // /usr/bin/clang shim, which results in the default SDK sysroot path // missing (PYSIDE-1032) - const QString &cmakeCompiler = compilerFromCMake(); - return platform() != Platform::macOS && !cmakeCompiler.isEmpty() - ? cmakeCompiler : defaultCompiler; + if (platform() == Platform::macOS) + return defaultCompiler; + QString cmakeCompiler = compilerFromCMake(); + if (cmakeCompiler.isEmpty()) + return defaultCompiler; + QFileInfo fi(cmakeCompiler); + // Should be absolute by default, but a user may specify -DCMAKE_CXX_COMPILER=cl.exe + if (fi.isRelative()) + return cmakeCompiler; + if (fi.exists()) + return fi.absoluteFilePath(); + // The compiler may not exist in case something like icecream or + // a non-standard-path was used on the build machine. Check + // the executable. + cmakeCompiler = QStandardPaths::findExecutable(fi.fileName()); + return cmakeCompiler.isEmpty() ? defaultCompiler : cmakeCompiler; } static void appendClangBuiltinIncludes(HeaderPaths *p) -- cgit v1.2.3