Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions cli/cmdlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
mSettings->checkAllConfigurations = false; // Can be overridden with --max-configs or --force
const std::string projectFile = argv[i]+10;
ImportProject::Type projType = mSettings->project.import(projectFile, mSettings);
mSettings->project.projectType = projType;
if (projType == ImportProject::Type::CPPCHECK_GUI) {
mPathNames = mSettings->project.guiProject.pathNames;
for (const std::string &lib : mSettings->project.guiProject.libraries)
Expand Down Expand Up @@ -629,6 +630,13 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
}
}

// --project-configuration
else if (std::strncmp(argv[i], "--project-configuration=", 24) == 0) {
mVSConfig = argv[i] + 24;
if (!mVSConfig.empty() && (mSettings->project.projectType == ImportProject::Type::VS_SLN || mSettings->project.projectType == ImportProject::Type::VS_VCXPROJ))
mSettings->project.ignoreOtherConfigs(mVSConfig);
}

// Report progress
else if (std::strcmp(argv[i], "--report-progress") == 0) {
mSettings->reportProgress = true;
Expand Down Expand Up @@ -1108,6 +1116,11 @@ void CmdLineParser::printHelp()
" or Borland C++ Builder 6 (*.bpr). The files to analyse,\n"
" include paths, defines, platform and undefines in\n"
" the specified file will be used.\n"
" --project-configuration=<config>\n"
" If used together with a Visual Studio Solution (*.sln)\n"
" or Visual Studio Project (*.vcxproj) you can limit\n"
" the configuration cppcheck should check.\n"
" For example: ""--project-configuration=Release|Win32"""
" --max-configs=<limit>\n"
" Maximum number of configurations to check in a file\n"
" before skipping it. Default is '12'. If used together\n"
Expand Down
1 change: 1 addition & 0 deletions cli/cmdlineparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class CmdLineParser {
bool mShowVersion;
bool mShowErrorMessages;
bool mExitAfterPrint;
std::string mVSConfig;
};

/// @}
Expand Down
5 changes: 5 additions & 0 deletions lib/importproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
#include <sstream>


ImportProject::ImportProject()
{
projectType = Type::UNKNOWN;
}

void ImportProject::ignorePaths(const std::vector<std::string> &ipaths)
{
for (std::list<FileSettings>::iterator it = fileSettings.begin(); it != fileSettings.end();) {
Expand Down
3 changes: 3 additions & 0 deletions lib/importproject.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ class CPPCHECKLIB ImportProject {
void setIncludePaths(const std::string &basepath, const std::list<std::string> &in, std::map<std::string, std::string, cppcheck::stricmp> &variables);
};
std::list<FileSettings> fileSettings;
Type projectType;

ImportProject();

void selectOneVsConfig(cppcheck::Platform::PlatformType platform);

Expand Down
5 changes: 5 additions & 0 deletions man/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ Running Cppcheck on a Visual Studio project:

cppcheck --project=foobar.vcxproj

Both options will analyze all available configurations in the project(s).
Limiting on a single configuration:

cppcheck --project=foobar.sln "--project-configuration=Release|Win32"

In the `Cppcheck GUI` you have the choice to only analyze a single debug configuration. If you want to use this choice on the command line then create a `Cppcheck GUI` project with this activated and then import the GUI project file on the command line.

To ignore certain folders in the project you can use `-i`. This will skip analysis of source files in the `foo` folder.
Expand Down