@@ -122,6 +122,8 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
122122 bool def = false ;
123123 bool maxconfigs = false ;
124124
125+ ImportProject project;
126+
125127 mSettings .exename = Path::getCurrentExecutablePath (argv[0 ]);
126128
127129 for (int i = 1 ; i < argc; i++) {
@@ -666,24 +668,24 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
666668
667669 // --project
668670 else if (std::strncmp (argv[i], " --project=" , 10 ) == 0 ) {
669- if (mSettings . project .projectType != ImportProject::Type::NONE)
671+ if (project.projectType != ImportProject::Type::NONE)
670672 {
671673 mLogger .printError (" multiple --project options are not supported." );
672674 return false ;
673675 }
674676
675677 mSettings .checkAllConfigurations = false ; // Can be overridden with --max-configs or --force
676678 std::string projectFile = argv[i]+10 ;
677- ImportProject::Type projType = mSettings . project .import (projectFile, &mSettings );
678- mSettings . project .projectType = projType;
679+ ImportProject::Type projType = project.import (projectFile, &mSettings );
680+ project.projectType = projType;
679681 if (projType == ImportProject::Type::CPPCHECK_GUI) {
680- for (const std::string &lib : mSettings . project .guiProject .libraries )
682+ for (const std::string &lib : project.guiProject .libraries )
681683 mSettings .libraries .emplace_back (lib);
682684
683- const auto & excludedPaths = mSettings . project .guiProject .excludedPaths ;
685+ const auto & excludedPaths = project.guiProject .excludedPaths ;
684686 std::copy (excludedPaths.cbegin (), excludedPaths.cend (), std::back_inserter (mIgnoredPaths ));
685687
686- std::string platform (mSettings . project .guiProject .platform );
688+ std::string platform (project.guiProject .platform );
687689
688690 // keep existing platform from command-line intact
689691 if (!platform.empty ()) {
@@ -700,14 +702,16 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
700702 }
701703 }
702704
703- if (!mSettings .project .guiProject .projectFile .empty ()) {
704- projectFile = mSettings .project .guiProject .projectFile ;
705- projType = mSettings .project .import (mSettings .project .guiProject .projectFile , &mSettings );
705+ const auto & projectFileGui = project.guiProject .projectFile ;
706+ if (!projectFileGui.empty ()) {
707+ // read underlying project
708+ projectFile = projectFileGui;
709+ projType = project.import (projectFileGui, &mSettings );
706710 }
707711 }
708712 if (projType == ImportProject::Type::VS_SLN || projType == ImportProject::Type::VS_VCXPROJ) {
709- if (mSettings . project .guiProject .analyzeAllVsConfigs == " false" )
710- mSettings . project .selectOneVsConfig (mSettings .platform .type );
713+ if (project.guiProject .analyzeAllVsConfigs == " false" )
714+ project.selectOneVsConfig (mSettings .platform .type );
711715 if (!CppCheckExecutor::tryLoadLibrary (mSettings .library , argv[0 ], " windows.cfg" )) {
712716 // This shouldn't happen normally.
713717 mLogger .printError (" failed to load 'windows.cfg'. Your Cppcheck installation is broken. Please re-install." );
@@ -731,8 +735,8 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
731735 // --project-configuration
732736 else if (std::strncmp (argv[i], " --project-configuration=" , 24 ) == 0 ) {
733737 mVSConfig = argv[i] + 24 ;
734- if (!mVSConfig .empty () && (mSettings . project .projectType == ImportProject::Type::VS_SLN || mSettings . project .projectType == ImportProject::Type::VS_VCXPROJ))
735- mSettings . project .ignoreOtherConfigs (mVSConfig );
738+ if (!mVSConfig .empty () && (project.projectType == ImportProject::Type::VS_SLN || project.projectType == ImportProject::Type::VS_VCXPROJ))
739+ project.ignoreOtherConfigs (mVSConfig );
736740 }
737741
738742 // Only print something when there are errors
@@ -1028,7 +1032,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
10281032 substituteTemplateFormatStatic (mSettings .templateFormat );
10291033 substituteTemplateLocationStatic (mSettings .templateLocation );
10301034
1031- mSettings . project .ignorePaths (mIgnoredPaths );
1035+ project.ignorePaths (mIgnoredPaths );
10321036
10331037 if (mSettings .force || maxconfigs)
10341038 mSettings .checkAllConfigurations = true ;
@@ -1053,19 +1057,22 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
10531057 return true ;
10541058 }
10551059
1056- if (!mPathNames .empty () && mSettings . project .projectType != ImportProject::Type::NONE) {
1060+ if (!mPathNames .empty () && project.projectType != ImportProject::Type::NONE) {
10571061 mLogger .printError (" --project cannot be used in conjunction with source files." );
10581062 return false ;
10591063 }
10601064
10611065 // Print error only if we have "real" command and expect files
1062- if (!mExitAfterPrint && mPathNames .empty () && mSettings . project .guiProject .pathNames .empty () && mSettings . project .fileSettings .empty ()) {
1066+ if (!mExitAfterPrint && mPathNames .empty () && project.guiProject .pathNames .empty () && project.fileSettings .empty ()) {
10631067 mLogger .printError (" no C or C++ source files found." );
10641068 return false ;
10651069 }
10661070
1067- if (!mSettings .project .guiProject .pathNames .empty ())
1068- mPathNames = mSettings .project .guiProject .pathNames ;
1071+ if (!project.guiProject .pathNames .empty ())
1072+ mPathNames = project.guiProject .pathNames ;
1073+
1074+ if (!project.fileSettings .empty ())
1075+ mSettings .fileSettings = project.fileSettings ;
10691076
10701077 // Use paths _pathnames if no base paths for relative path output are given
10711078 if (mSettings .basePaths .empty () && mSettings .relativePaths )
0 commit comments