diff --git a/plugins/cmake/cmakeutils.h b/plugins/cmake/cmakeutils.h --- a/plugins/cmake/cmakeutils.h +++ b/plugins/cmake/cmakeutils.h @@ -262,7 +262,7 @@ KDEVCMAKECOMMON_EXPORT QString defaultGenerator(); - KDEVCMAKECOMMON_EXPORT QVector importTestSuites(const KDevelop::Path &buildDir); + KDEVCMAKECOMMON_EXPORT QVector importTestSuites(const KDevelop::Path &buildDir, const QString & CMakeTestFileName=QStringLiteral("CTestTestfile.cmake")); } #endif diff --git a/plugins/cmake/cmakeutils.cpp b/plugins/cmake/cmakeutils.cpp --- a/plugins/cmake/cmakeutils.cpp +++ b/plugins/cmake/cmakeutils.cpp @@ -691,22 +691,27 @@ return defGen; } -QVector importTestSuites(const Path &buildDir) +QVector importTestSuites(const Path &buildDir, const QString & CMakeTestFileName) { - const auto contents = CMakeListsParser::readCMakeFile(buildDir.toLocalFile() + QLatin1String("/CTestTestfile.cmake")); - + auto CMakeTestFile = Path(buildDir, CMakeTestFileName).toLocalFile() ; + const auto contents = CMakeListsParser::readCMakeFile(CMakeTestFile); + QVector tests; for (const auto& entry: contents) { if (entry.name == QLatin1String("add_test")) { auto args = entry.arguments; - + Test test; test.name = args.takeFirst().value; test.executable = args.takeFirst().value; test.arguments = kTransform(args, [](const CMakeFunctionArgument& arg) { return arg.value; }); + tests += test; } else if (entry.name == QLatin1String("subdirs")) { tests += importTestSuites(Path(buildDir, entry.arguments.first().value)); + } else if (entry.name == QLatin1String("include")) { + // Include directive points directly to a .cmake file hosting the tests + tests += importTestSuites(Path(buildDir, entry.arguments.first().value), QStringLiteral("")); } else if (entry.name == QLatin1String("set_tests_properties")) { if(entry.arguments.count() < 4 || entry.arguments.count() % 2) { qCWarning(CMAKE) << "found set_tests_properties() with unexpected number of arguments:" diff --git a/plugins/cmake/parser/cmakelistsparser.cpp b/plugins/cmake/parser/cmakelistsparser.cpp --- a/plugins/cmake/parser/cmakelistsparser.cpp +++ b/plugins/cmake/parser/cmakelistsparser.cpp @@ -188,7 +188,9 @@ func.arguments << CMakeFunctionArgument( QString::fromLocal8Bit(token->text, token->length), false, token->line, token->column ); break; case cmListFileLexer_Token_Identifier: + case cmListFileLexer_Token_ArgumentBracket: case cmListFileLexer_Token_ArgumentUnquoted: + func.arguments << CMakeFunctionArgument( QString::fromLocal8Bit(token->text, token->length), false, token->line, token->column ); break; case cmListFileLexer_Token_ArgumentQuoted: