File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 2525#include < QInputDialog>
2626#include < QDir>
2727#include < QSettings>
28+ #include < QProcess>
2829#include " common.h"
2930#include " projectfiledialog.h"
3031#include " projectfile.h"
3132#include " library.h"
3233#include " cppcheck.h"
3334#include " errorlogger.h"
3435
36+ static QString clangTidyCmd () {
37+ QString path = QSettings ().value (SETTINGS_CLANG_PATH,QString ()).toString ();
38+ if (!path.isEmpty ())
39+ path += ' /' ;
40+ path += " clang-tidy" ;
41+ #ifdef Q_OS_WIN
42+ path += " .exe" ;
43+ #endif
44+
45+ QProcess process;
46+ process.start (path, QStringList () << " --version" );
47+ process.waitForFinished ();
48+ if (process.exitCode () == 0 )
49+ return path;
50+
51+ #ifdef Q_OS_WIN
52+ // Try to autodetect clang-tidy
53+ if (QFileInfo (" C:/Program Files/LLVM/bin/clang-tidy.exe" ).exists ())
54+ return " C:/Program Files/LLVM/bin/clang-tidy.exe" ;
55+ #endif
56+
57+ return QString ();
58+ }
59+
3560ProjectFileDialog::ProjectFileDialog (ProjectFile *projectFile, QWidget *parent)
3661 : QDialog(parent)
3762 , mProjectFile(projectFile)
@@ -151,6 +176,10 @@ void ProjectFileDialog::loadFromProjectFile(const ProjectFile *projectFile)
151176 mUI .mAddonCert ->setChecked (projectFile->getAddons ().contains (" cert" ));
152177 mUI .mToolClangAnalyzer ->setChecked (projectFile->getClangAnalyzer ());
153178 mUI .mToolClangTidy ->setChecked (projectFile->getClangTidy ());
179+ if (clangTidyCmd ().isEmpty ()) {
180+ mUI .mToolClangTidy ->setText (tr (" Clang-tidy (not found)" ));
181+ mUI .mToolClangTidy ->setEnabled (false );
182+ }
154183 QString tags;
155184 foreach (const QString tag, projectFile->getTags ()) {
156185 if (tags.isEmpty ())
You can’t perform that action at this time.
0 commit comments