diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 90d403cdb8..8d802a38eb 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1649,7 +1649,7 @@ bool cmGlobalGenerator::Compute() &exportSet.second, dest, "", std::vector(), "", cmInstallGenerator::SelectMessageLevel(this->Makefiles[0].get()), false, std::move(sbomDefaultArgs), "", - this->Makefiles[0]->GetBacktrace())); + cmInstallGenerator::CaptureContext(this->Makefiles[0].get()))); } } #endif diff --git a/Source/cmInstallAndroidMKExportGenerator.cxx b/Source/cmInstallAndroidMKExportGenerator.cxx index 12b212fe6e..8f3fc2143b 100644 --- a/Source/cmInstallAndroidMKExportGenerator.cxx +++ b/Source/cmInstallAndroidMKExportGenerator.cxx @@ -6,9 +6,9 @@ #include +#include "cmDiagnosticContext.h" #include "cmExportInstallAndroidMKGenerator.h" #include "cmExportInstallFileGenerator.h" -#include "cmListFileCache.h" class cmExportSet; @@ -16,12 +16,12 @@ cmInstallAndroidMKExportGenerator::cmInstallAndroidMKExportGenerator( cmExportSet* exportSet, std::string destination, std::string filePermissions, std::vector const& configurations, std::string component, MessageLevel message, bool excludeFromAll, std::string filename, - std::string targetNamespace, cmListFileBacktrace backtrace) + std::string targetNamespace, cmDiagnosticContext context) : cmInstallExportGenerator(exportSet, std::move(destination), std::move(filePermissions), configurations, std::move(component), message, excludeFromAll, std::move(filename), std::move(targetNamespace), - std::string{}, std::move(backtrace)) + std::string{}, std::move(context)) { this->EFGen = cm::make_unique(this); } diff --git a/Source/cmInstallAndroidMKExportGenerator.h b/Source/cmInstallAndroidMKExportGenerator.h index 1167a8a4f7..485e6b28d3 100644 --- a/Source/cmInstallAndroidMKExportGenerator.h +++ b/Source/cmInstallAndroidMKExportGenerator.h @@ -7,8 +7,8 @@ #include "cmInstallExportGenerator.h" +class cmDiagnosticContext; class cmExportSet; -class cmListFileBacktrace; /** \class cmInstallAndroidMKExportGenerator * \brief Generate rules for creating Android .mk export files. @@ -21,7 +21,7 @@ public: std::string filePermissions, std::vector const& configurations, std::string component, MessageLevel message, bool excludeFromAll, std::string filename, - std::string targetNamespace, cmListFileBacktrace backtrace); + std::string targetNamespace, cmDiagnosticContext context); cmInstallAndroidMKExportGenerator(cmInstallAndroidMKExportGenerator const&) = delete; ~cmInstallAndroidMKExportGenerator() override; diff --git a/Source/cmInstallCMakeConfigExportGenerator.cxx b/Source/cmInstallCMakeConfigExportGenerator.cxx index 4f5b82ea12..e02320139b 100644 --- a/Source/cmInstallCMakeConfigExportGenerator.cxx +++ b/Source/cmInstallCMakeConfigExportGenerator.cxx @@ -6,9 +6,9 @@ #include +#include "cmDiagnosticContext.h" #include "cmExportInstallCMakeConfigGenerator.h" #include "cmExportInstallFileGenerator.h" -#include "cmListFileCache.h" class cmExportSet; @@ -17,12 +17,12 @@ cmInstallCMakeConfigExportGenerator::cmInstallCMakeConfigExportGenerator( std::vector const& configurations, std::string component, MessageLevel message, bool excludeFromAll, std::string filename, std::string targetNamespace, std::string cxxModulesDirectory, bool exportOld, - bool exportPackageDependencies, cmListFileBacktrace backtrace) + bool exportPackageDependencies, cmDiagnosticContext context) : cmInstallExportGenerator( exportSet, std::move(destination), std::move(filePermissions), configurations, std::move(component), message, excludeFromAll, std::move(filename), std::move(targetNamespace), - std::move(cxxModulesDirectory), std::move(backtrace)) + std::move(cxxModulesDirectory), std::move(context)) , ExportOld(exportOld) , ExportPackageDependencies(exportPackageDependencies) { diff --git a/Source/cmInstallCMakeConfigExportGenerator.h b/Source/cmInstallCMakeConfigExportGenerator.h index 6ca5c9a796..d655dad04e 100644 --- a/Source/cmInstallCMakeConfigExportGenerator.h +++ b/Source/cmInstallCMakeConfigExportGenerator.h @@ -8,8 +8,8 @@ #include "cmInstallExportGenerator.h" +class cmDiagnosticContext; class cmExportSet; -class cmListFileBacktrace; /** \class cmInstallCMakeConfigExportGenerator * \brief Generate rules for creating CMake export files. @@ -24,7 +24,7 @@ public: MessageLevel message, bool excludeFromAll, std::string filename, std::string targetNamespace, std::string cxxModulesDirectory, bool exportOld, bool exportPackageDependencies, - cmListFileBacktrace backtrace); + cmDiagnosticContext context); cmInstallCMakeConfigExportGenerator( cmInstallCMakeConfigExportGenerator const&) = delete; ~cmInstallCMakeConfigExportGenerator() override; diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 5a3c72d355..a0d032cad3 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -20,6 +20,7 @@ #include "cmArgumentParser.h" #include "cmArgumentParserTypes.h" #include "cmCMakePath.h" +#include "cmDiagnosticContext.h" #include "cmDiagnostics.h" #include "cmExecutionStatus.h" #include "cmExperimental.h" @@ -59,8 +60,6 @@ #include "cmTargetExport.h" #include "cmValue.h" -class cmListFileBacktrace; - namespace { struct RuntimeDependenciesArgs @@ -108,6 +107,11 @@ public: } } + cmDiagnosticContext CaptureContext() const + { + return cmInstallGenerator::CaptureContext(this->Makefile); + } + void SetError(std::string const& err) { this->Status.SetError(err); } bool MakeFilesFullPath(char const* modeName, @@ -137,7 +141,7 @@ public: std::unique_ptr CreateInstallTargetGenerator( cmTarget& target, cmInstallCommandArguments const& args, bool impLib, - cmListFileBacktrace const& backtrace, std::string const& destination, + cmDiagnosticContext context, std::string const& destination, bool forceOpt = false, bool namelink = false) { cmInstallGenerator::MessageLevel message = @@ -148,17 +152,16 @@ std::unique_ptr CreateInstallTargetGenerator( auto g = cm::make_unique( target.GetName(), destination, impLib, args.GetPermissions(), args.GetConfigurations(), component, message, args.GetExcludeFromAll(), - args.GetOptional() || forceOpt, backtrace); + args.GetOptional() || forceOpt, std::move(context)); target.AddInstallGenerator(g.get()); return g; } std::unique_ptr CreateInstallTargetGenerator( cmTarget& target, cmInstallCommandArguments const& args, bool impLib, - cmListFileBacktrace const& backtrace, bool forceOpt = false, - bool namelink = false) + cmDiagnosticContext context, bool forceOpt = false, bool namelink = false) { - return CreateInstallTargetGenerator(target, args, impLib, backtrace, + return CreateInstallTargetGenerator(target, args, impLib, std::move(context), args.GetDestination(), forceOpt, namelink); } @@ -174,7 +177,7 @@ std::unique_ptr CreateInstallFilesGenerator( absFiles, destination, programs, args.GetPermissions(), args.GetConfigurations(), args.GetComponent(), message, args.GetExcludeFromAll(), args.GetRename(), args.GetOptional(), - mf->GetBacktrace()); + cmInstallGenerator::CaptureContext(mf)); } std::unique_ptr CreateInstallFilesGenerator( @@ -195,7 +198,7 @@ std::unique_ptr CreateInstallFileSetGenerator( target.GetName(), args.GetFileSet(), args.GetDestination(), args.GetPermissions(), args.GetConfigurations(), args.GetComponent(), message, args.GetExcludeFromAll(), args.GetOptional(), - helper.Makefile->GetBacktrace()); + helper.CaptureContext()); } void AddInstallRuntimeDependenciesGenerator( @@ -253,8 +256,7 @@ void AddInstallRuntimeDependenciesGenerator( runtimeDependenciesArgsRef.GetComponent(), runtimeDependenciesArgsRef.GetPermissions(), cmInstallGenerator::SelectMessageLevel(helper.Makefile), - runtimeDependenciesArgsRef.GetExcludeFromAll(), - helper.Makefile->GetBacktrace()); + runtimeDependenciesArgsRef.GetExcludeFromAll(), helper.CaptureContext()); helper.Makefile->AddInstallGenerator( std::move(libraryRuntimeDependenciesGenerator)); if (dllPlatform) { @@ -273,7 +275,7 @@ void AddInstallRuntimeDependenciesGenerator( frameworkArgs.GetDestination(), frameworkArgs.GetConfigurations(), frameworkArgs.GetComponent(), frameworkArgs.GetPermissions(), cmInstallGenerator::SelectMessageLevel(helper.Makefile), - frameworkArgs.GetExcludeFromAll(), helper.Makefile->GetBacktrace()); + frameworkArgs.GetExcludeFromAll(), helper.CaptureContext()); helper.Makefile->AddInstallGenerator( std::move(frameworkRuntimeDependenciesGenerator)); installsFramework = true; @@ -830,21 +832,21 @@ bool HandleTargetsMode(std::vector const& args, if (!archiveArgs.GetDestination().empty()) { // The import library uses the ARCHIVE properties. archiveGenerator = CreateInstallTargetGenerator( - target, archiveArgs, true, helper.Makefile->GetBacktrace()); + target, archiveArgs, true, helper.CaptureContext()); artifactsSpecified = true; } if (!runtimeArgs.GetDestination().empty()) { // The DLL uses the RUNTIME properties. runtimeGenerator = CreateInstallTargetGenerator( - target, runtimeArgs, false, helper.Makefile->GetBacktrace()); + target, runtimeArgs, false, helper.CaptureContext()); artifactsSpecified = true; } if (!archiveGenerator && !runtimeGenerator) { archiveGenerator = CreateInstallTargetGenerator( - target, archiveArgs, true, helper.Makefile->GetBacktrace(), + target, archiveArgs, true, helper.CaptureContext(), helper.GetArchiveDestination(nullptr)); runtimeGenerator = CreateInstallTargetGenerator( - target, runtimeArgs, false, helper.Makefile->GetBacktrace(), + target, runtimeArgs, false, helper.CaptureContext(), helper.GetRuntimeDestination(nullptr)); } if (runtimeDependencySet && runtimeGenerator) { @@ -867,7 +869,7 @@ bool HandleTargetsMode(std::vector const& args, // Use the FRAMEWORK properties. if (!frameworkArgs.GetDestination().empty()) { frameworkGenerator = CreateInstallTargetGenerator( - target, frameworkArgs, false, helper.Makefile->GetBacktrace()); + target, frameworkArgs, false, helper.CaptureContext()); } else { status.SetError( cmStrCat("TARGETS given no FRAMEWORK DESTINATION for shared " @@ -882,14 +884,14 @@ bool HandleTargetsMode(std::vector const& args, } if (namelinkMode != cmInstallTargetGenerator::NamelinkModeOnly) { libraryGenerator = CreateInstallTargetGenerator( - target, libraryArgs, false, helper.Makefile->GetBacktrace(), + target, libraryArgs, false, helper.CaptureContext(), helper.GetLibraryDestination(&libraryArgs)); libraryGenerator->SetNamelinkMode( cmInstallTargetGenerator::NamelinkModeSkip); } if (namelinkMode != cmInstallTargetGenerator::NamelinkModeSkip) { namelinkGenerator = CreateInstallTargetGenerator( - target, libraryArgs, false, helper.Makefile->GetBacktrace(), + target, libraryArgs, false, helper.CaptureContext(), helper.GetLibraryDestination(&libraryArgs), false, true); namelinkGenerator->SetNamelinkMode( cmInstallTargetGenerator::NamelinkModeOnly); @@ -906,7 +908,7 @@ bool HandleTargetsMode(std::vector const& args, if (importlinkMode != cmInstallTargetGenerator::NamelinkModeOnly) { archiveGenerator = CreateInstallTargetGenerator( - target, archiveArgs, true, helper.Makefile->GetBacktrace(), + target, archiveArgs, true, helper.CaptureContext(), helper.GetLibraryDestination(&archiveArgs)); archiveGenerator->SetImportlinkMode( cmInstallTargetGenerator::NamelinkModeSkip); @@ -914,7 +916,7 @@ bool HandleTargetsMode(std::vector const& args, if (importlinkMode != cmInstallTargetGenerator::NamelinkModeSkip) { importlinkGenerator = CreateInstallTargetGenerator( - target, archiveArgs, true, helper.Makefile->GetBacktrace(), + target, archiveArgs, true, helper.CaptureContext(), helper.GetLibraryDestination(&archiveArgs), false, true); importlinkGenerator->SetImportlinkMode( cmInstallTargetGenerator::NamelinkModeOnly); @@ -944,7 +946,7 @@ bool HandleTargetsMode(std::vector const& args, // Use the FRAMEWORK properties. if (!frameworkArgs.GetDestination().empty()) { frameworkGenerator = CreateInstallTargetGenerator( - target, frameworkArgs, false, helper.Makefile->GetBacktrace()); + target, frameworkArgs, false, helper.CaptureContext()); } else { status.SetError( cmStrCat("TARGETS given no FRAMEWORK DESTINATION for static " @@ -958,7 +960,7 @@ bool HandleTargetsMode(std::vector const& args, artifactsSpecified = true; } archiveGenerator = CreateInstallTargetGenerator( - target, archiveArgs, false, helper.Makefile->GetBacktrace(), + target, archiveArgs, false, helper.CaptureContext(), helper.GetArchiveDestination(&archiveArgs)); } } break; @@ -966,7 +968,7 @@ bool HandleTargetsMode(std::vector const& args, // Modules use LIBRARY properties. if (!libraryArgs.GetDestination().empty()) { libraryGenerator = CreateInstallTargetGenerator( - target, libraryArgs, false, helper.Makefile->GetBacktrace()); + target, libraryArgs, false, helper.CaptureContext()); libraryGenerator->SetNamelinkMode(namelinkMode); namelinkOnly = (namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly); @@ -994,7 +996,7 @@ bool HandleTargetsMode(std::vector const& args, } objectGenerator = CreateInstallTargetGenerator( - target, objectArgs, false, helper.Makefile->GetBacktrace()); + target, objectArgs, false, helper.CaptureContext()); } else { // Installing an OBJECT library without a destination transforms // it to an INTERFACE library. It installs no files but can be @@ -1006,7 +1008,7 @@ bool HandleTargetsMode(std::vector const& args, // Application bundles use the BUNDLE properties. if (!bundleArgs.GetDestination().empty()) { bundleGenerator = CreateInstallTargetGenerator( - target, bundleArgs, false, helper.Makefile->GetBacktrace()); + target, bundleArgs, false, helper.CaptureContext()); } if (!bundleGenerator) { status.SetError(cmStrCat("TARGETS given no BUNDLE DESTINATION for " @@ -1026,7 +1028,7 @@ bool HandleTargetsMode(std::vector const& args, artifactsSpecified = true; } runtimeGenerator = CreateInstallTargetGenerator( - target, runtimeArgs, false, helper.Makefile->GetBacktrace(), + target, runtimeArgs, false, helper.CaptureContext(), helper.GetRuntimeDestination(&runtimeArgs)); if (runtimeDependencySet) { runtimeDependencySet->AddExecutable(runtimeGenerator.get()); @@ -1042,7 +1044,7 @@ bool HandleTargetsMode(std::vector const& args, // The import library uses the ARCHIVE properties. artifactsSpecified = true; archiveGenerator = CreateInstallTargetGenerator( - target, archiveArgs, true, helper.Makefile->GetBacktrace(), true); + target, archiveArgs, true, helper.CaptureContext(), true); } } break; case cmStateEnums::INTERFACE_LIBRARY: @@ -1150,7 +1152,7 @@ bool HandleTargetsMode(std::vector const& args, cxxModuleBmiArgs.GetConfigurations(), cxxModuleBmiArgs.GetComponent(), cmInstallGenerator::SelectMessageLevel(target.GetMakefile()), cxxModuleBmiArgs.GetExcludeFromAll(), cxxModuleBmiArgs.GetOptional(), - helper.Makefile->GetBacktrace()); + helper.CaptureContext()); target.SetHaveInstallRule(true); } @@ -1407,7 +1409,7 @@ bool HandleImportedRuntimeArtifactsMode(std::vector const& args, typeArgs.GetConfigurations(), typeArgs.GetComponent(), cmInstallGenerator::SelectMessageLevel(helper.Makefile), typeArgs.GetExcludeFromAll(), typeArgs.GetOptional(), - helper.Makefile->GetBacktrace()); + helper.CaptureContext()); }; // Generate install script code to install the given targets. @@ -1925,7 +1927,7 @@ bool HandleDirectoryMode(std::vector const& args, cm::make_unique( dirs, *destination, permissionsFile, permissionsDir, configurations, component, message, excludeFromAll, literalArgs, optional, - helper.Makefile->GetBacktrace())); + helper.CaptureContext())); // Tell the global generator about any installation component names // specified. @@ -2022,7 +2024,7 @@ bool HandleExportAndroidMKMode(std::vector const& args, &exportSet, ica.GetDestination(), ica.GetPermissions(), ica.GetConfigurations(), ica.GetComponent(), message, ica.GetExcludeFromAll(), std::move(fname), std::move(exportNamespace), - helper.Makefile->GetBacktrace())); + helper.CaptureContext())); return true; #else @@ -2172,7 +2174,7 @@ bool HandleMappedPackageInfo( installCommandArgs.GetConfigurations(), installCommandArgs.GetComponent(), message, installCommandArgs.GetExcludeFromAll(), std::move(arguments), - cxxModulesDirectory, helper.Makefile->GetBacktrace())); + cxxModulesDirectory, helper.CaptureContext())); return true; } @@ -2303,7 +2305,7 @@ bool HandleExportMode(std::vector const& args, ica.GetConfigurations(), ica.GetComponent(), message, ica.GetExcludeFromAll(), std::move(fname), std::move(exportNamespace), std::move(cxxModulesDirectory), exportOld, exportPackageDependencies, - helper.Makefile->GetBacktrace())); + helper.CaptureContext())); return true; } @@ -2373,7 +2375,7 @@ bool HandlePackageInfoMode(std::vector const& args, &exportSet, dest, ica.GetPermissions(), ica.GetConfigurations(), ica.GetComponent(), message, ica.GetExcludeFromAll(), std::move(arguments), std::move(cxxModulesDirectory), - helper.Makefile->GetBacktrace())); + helper.CaptureContext())); return true; #else @@ -2576,7 +2578,7 @@ bool HandleSbomMode(std::vector const& args, &exportSet, dest, ica.GetPermissions(), ica.GetConfigurations(), ica.GetComponent(), message, ica.GetExcludeFromAll(), std::move(arguments), std::move(cxxModulesDirectory), - helper.Makefile->GetBacktrace())); + helper.CaptureContext())); return true; #else diff --git a/Source/cmInstallCxxModuleBmiGenerator.cxx b/Source/cmInstallCxxModuleBmiGenerator.cxx index 99e32cb4fa..99df879cca 100644 --- a/Source/cmInstallCxxModuleBmiGenerator.cxx +++ b/Source/cmInstallCxxModuleBmiGenerator.cxx @@ -5,10 +5,10 @@ #include #include +#include "cmDiagnosticContext.h" #include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" -#include "cmListFileCache.h" #include "cmLocalGenerator.h" #include "cmScriptGenerator.h" #include "cmStringAlgorithms.h" @@ -17,9 +17,9 @@ cmInstallCxxModuleBmiGenerator::cmInstallCxxModuleBmiGenerator( std::string target, std::string const& dest, std::string filePermissions, std::vector const& configurations, std::string const& component, MessageLevel message, bool excludeFromAll, bool optional, - cmListFileBacktrace backtrace) + cmDiagnosticContext context) : cmInstallGenerator(dest, configurations, component, message, - excludeFromAll, false, std::move(backtrace)) + excludeFromAll, false, std::move(context)) , TargetName(std::move(target)) , FilePermissions(std::move(filePermissions)) , Optional(optional) diff --git a/Source/cmInstallCxxModuleBmiGenerator.h b/Source/cmInstallCxxModuleBmiGenerator.h index 28ed2b5951..cb34266130 100644 --- a/Source/cmInstallCxxModuleBmiGenerator.h +++ b/Source/cmInstallCxxModuleBmiGenerator.h @@ -10,8 +10,8 @@ #include "cmInstallGenerator.h" +class cmDiagnosticContext; class cmGeneratorTarget; -class cmListFileBacktrace; class cmLocalGenerator; /** \class cmInstallCxxModuleBmiGenerator @@ -24,7 +24,7 @@ public: std::string target, std::string const& dest, std::string filePermissions, std::vector const& configurations, std::string const& component, MessageLevel message, bool excludeFromAll, - bool optional, cmListFileBacktrace backtrace); + bool optional, cmDiagnosticContext context); ~cmInstallCxxModuleBmiGenerator() override; bool Compute(cmLocalGenerator* lg) override; diff --git a/Source/cmInstallDirectoryGenerator.cxx b/Source/cmInstallDirectoryGenerator.cxx index 96d32ba3e8..ea43e5b184 100644 --- a/Source/cmInstallDirectoryGenerator.cxx +++ b/Source/cmInstallDirectoryGenerator.cxx @@ -5,10 +5,10 @@ #include #include +#include "cmDiagnosticContext.h" #include "cmGeneratorExpression.h" #include "cmInstallType.h" #include "cmList.h" -#include "cmListFileCache.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmStringAlgorithms.h" @@ -19,9 +19,9 @@ cmInstallDirectoryGenerator::cmInstallDirectoryGenerator( std::string filePermissions, std::string dirPermissions, std::vector const& configurations, std::string const& component, MessageLevel message, bool excludeFromAll, std::string literalArgs, - bool optional, cmListFileBacktrace backtrace) + bool optional, cmDiagnosticContext context) : cmInstallGenerator(dest, configurations, component, message, - excludeFromAll, false, std::move(backtrace)) + excludeFromAll, false, std::move(context)) , Directories(dirs) , FilePermissions(std::move(filePermissions)) , DirPermissions(std::move(dirPermissions)) @@ -120,7 +120,6 @@ std::string cmInstallDirectoryGenerator::GetDestination( { std::string dest = cmGeneratorExpression::Evaluate( this->Destination, this->LocalGenerator, config); - cmInstallGenerator::CheckAbsoluteDestination(dest, this->LocalGenerator, - this->Backtrace); + this->CheckAbsoluteDestination(dest, this->LocalGenerator); return dest; } diff --git a/Source/cmInstallDirectoryGenerator.h b/Source/cmInstallDirectoryGenerator.h index d228f9b5fd..7f85748b2b 100644 --- a/Source/cmInstallDirectoryGenerator.h +++ b/Source/cmInstallDirectoryGenerator.h @@ -10,7 +10,7 @@ #include "cmInstallGenerator.h" -class cmListFileBacktrace; +class cmDiagnosticContext; class cmLocalGenerator; /** \class cmInstallDirectoryGenerator @@ -24,7 +24,7 @@ public: std::string filePermissions, std::string dirPermissions, std::vector const& configurations, std::string const& component, MessageLevel message, bool excludeFromAll, - std::string literalArgs, bool optional, cmListFileBacktrace backtrace); + std::string literalArgs, bool optional, cmDiagnosticContext context); ~cmInstallDirectoryGenerator() override; bool Compute(cmLocalGenerator* lg) override; diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index 7f2474d2c3..007694eaa9 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -7,10 +7,10 @@ #include #include "cmCryptoHash.h" +#include "cmDiagnosticContext.h" #include "cmExportInstallFileGenerator.h" #include "cmExportSet.h" #include "cmInstallType.h" -#include "cmListFileCache.h" #include "cmLocalGenerator.h" #include "cmScriptGenerator.h" #include "cmStringAlgorithms.h" @@ -21,10 +21,10 @@ cmInstallExportGenerator::cmInstallExportGenerator( std::vector const& configurations, std::string component, MessageLevel message, bool excludeFromAll, std::string filename, std::string targetNamespace, std::string cxxModulesDirectory, - cmListFileBacktrace backtrace) + cmDiagnosticContext context) : cmInstallGenerator(std::move(destination), configurations, std::move(component), message, excludeFromAll, false, - std::move(backtrace)) + std::move(context)) , ExportSet(exportSet) , FilePermissions(std::move(filePermissions)) , FileName(std::move(filename)) diff --git a/Source/cmInstallExportGenerator.h b/Source/cmInstallExportGenerator.h index eb2d5dd811..167cf10815 100644 --- a/Source/cmInstallExportGenerator.h +++ b/Source/cmInstallExportGenerator.h @@ -11,9 +11,9 @@ #include "cmInstallGenerator.h" +class cmDiagnosticContext; class cmExportInstallFileGenerator; class cmExportSet; -class cmListFileBacktrace; class cmLocalGenerator; /** \class cmInstallExportGenerator @@ -29,7 +29,7 @@ public: bool excludeFromAll, std::string filename, std::string targetNamespace, std::string cxxModulesDirectory, - cmListFileBacktrace backtrace); + cmDiagnosticContext context); cmInstallExportGenerator(cmInstallExportGenerator const&) = delete; ~cmInstallExportGenerator() override; diff --git a/Source/cmInstallFileSetGenerator.cxx b/Source/cmInstallFileSetGenerator.cxx index 60bacc95ad..250f207c69 100644 --- a/Source/cmInstallFileSetGenerator.cxx +++ b/Source/cmInstallFileSetGenerator.cxx @@ -11,6 +11,7 @@ #include +#include "cmDiagnosticContext.h" #include "cmFileSetMetadata.h" #include "cmGenExContext.h" #include "cmGeneratorExpression.h" @@ -20,7 +21,6 @@ #include "cmInstallDirs.h" #include "cmInstallType.h" #include "cmList.h" -#include "cmListFileCache.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmMessageType.h" @@ -31,9 +31,9 @@ cmInstallFileSetGenerator::cmInstallFileSetGenerator( std::string targetName, std::string fileSetName, std::string destination, std::string filePermissions, std::vector const& configurations, std::string const& component, MessageLevel message, bool excludeFromAll, - bool optional, cmListFileBacktrace backtrace) + bool optional, cmDiagnosticContext context) : cmInstallGenerator(std::move(destination), configurations, component, - message, excludeFromAll, false, std::move(backtrace)) + message, excludeFromAll, false, std::move(context)) , TargetName(std::move(targetName)) , FileSetName(std::move(fileSetName)) , FilePermissions(std::move(filePermissions)) @@ -95,8 +95,7 @@ bool cmInstallFileSetGenerator::Compute(cmLocalGenerator* lg) std::string cmInstallFileSetGenerator::GetDestination() const { - cmInstallGenerator::CheckAbsoluteDestination( - this->Destination, this->LocalGenerator, this->Backtrace); + this->CheckAbsoluteDestination(this->Destination, this->LocalGenerator); return this->Destination; } @@ -115,8 +114,7 @@ cmInstallFileSetGenerator::GetDestination(cmGeneratorTarget* gte, ge.Parse(this->Destination); std::string const dest = cge->Evaluate(gte->LocalGenerator, config, gte); - cmInstallGenerator::CheckAbsoluteDestination(dest, gte->LocalGenerator, - this->Backtrace); + this->CheckAbsoluteDestination(dest, gte->LocalGenerator); return { dest, cge->GetHadContextSensitiveCondition() }; } diff --git a/Source/cmInstallFileSetGenerator.h b/Source/cmInstallFileSetGenerator.h index 85866925a0..72b9682d6a 100644 --- a/Source/cmInstallFileSetGenerator.h +++ b/Source/cmInstallFileSetGenerator.h @@ -9,10 +9,10 @@ #include "cmInstallGenerator.h" +class cmDiagnosticContext; class cmExportInstallCMakeConfigGenerator; class cmGeneratorFileSet; class cmGeneratorTarget; -class cmListFileBacktrace; class cmLocalGenerator; class cmInstallFileSetGenerator : public cmInstallGenerator @@ -24,7 +24,7 @@ public: std::vector const& configurations, std::string const& component, MessageLevel message, bool excludeFromAll, bool optional, - cmListFileBacktrace backtrace); + cmDiagnosticContext context); ~cmInstallFileSetGenerator() override; bool Compute(cmLocalGenerator* lg) override; diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx index 8490f697b8..7e2fb69070 100644 --- a/Source/cmInstallFilesCommand.cxx +++ b/Source/cmInstallFilesCommand.cxx @@ -125,7 +125,8 @@ static void CreateInstallGenerator(cmMakefile& makefile, cmInstallGenerator::SelectMessageLevel(&makefile); makefile.AddInstallGenerator(cm::make_unique( files, destination, false, no_permissions, no_configurations, no_component, - message, no_exclude_from_all, no_rename, false, makefile.GetBacktrace())); + message, no_exclude_from_all, no_rename, false, + cmInstallGenerator::CaptureContext(makefile))); } /** diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx index bc9517a1ea..387914a77b 100644 --- a/Source/cmInstallFilesGenerator.cxx +++ b/Source/cmInstallFilesGenerator.cxx @@ -4,19 +4,19 @@ #include +#include "cmDiagnosticContext.h" #include "cmGeneratorExpression.h" #include "cmInstallType.h" #include "cmList.h" -#include "cmListFileCache.h" cmInstallFilesGenerator::cmInstallFilesGenerator( std::vector const& files, std::string const& dest, bool programs, std::string filePermissions, std::vector const& configurations, std::string const& component, MessageLevel message, bool excludeFromAll, std::string rename, bool optional, - cmListFileBacktrace backtrace) + cmDiagnosticContext context) : cmInstallGenerator(dest, configurations, component, message, - excludeFromAll, false, std::move(backtrace)) + excludeFromAll, false, std::move(context)) , Files(files) , FilePermissions(std::move(filePermissions)) , Rename(std::move(rename)) @@ -56,8 +56,7 @@ std::string cmInstallFilesGenerator::GetDestination( { std::string dest = cmGeneratorExpression::Evaluate( this->Destination, this->LocalGenerator, config); - cmInstallGenerator::CheckAbsoluteDestination(dest, this->LocalGenerator, - this->Backtrace); + this->CheckAbsoluteDestination(dest, this->LocalGenerator); return dest; } diff --git a/Source/cmInstallFilesGenerator.h b/Source/cmInstallFilesGenerator.h index c8f4842b89..5f61384306 100644 --- a/Source/cmInstallFilesGenerator.h +++ b/Source/cmInstallFilesGenerator.h @@ -10,7 +10,7 @@ #include "cmInstallGenerator.h" -class cmListFileBacktrace; +class cmDiagnosticContext; class cmLocalGenerator; /** \class cmInstallFilesGenerator @@ -25,7 +25,7 @@ public: std::vector const& configurations, std::string const& component, MessageLevel message, bool excludeFromAll, std::string rename, - bool optional, cmListFileBacktrace backtrace); + bool optional, cmDiagnosticContext context); ~cmInstallFilesGenerator() override; bool Compute(cmLocalGenerator* lg) override; diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx index 585bf80cb2..ef84ae2ee2 100644 --- a/Source/cmInstallGenerator.cxx +++ b/Source/cmInstallGenerator.cxx @@ -8,7 +8,6 @@ #include #include "cmDiagnostics.h" -#include "cmListFileCache.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmStringAlgorithms.h" @@ -17,14 +16,14 @@ cmInstallGenerator::cmInstallGenerator( std::string destination, std::vector const& configurations, std::string component, MessageLevel message, bool excludeFromAll, - bool allComponents, cmListFileBacktrace backtrace) + bool allComponents, cmDiagnosticContext context) : cmScriptGenerator("CMAKE_INSTALL_CONFIG_NAME", configurations) , Destination(std::move(destination)) , Component(std::move(component)) , Message(message) , ExcludeFromAll(excludeFromAll) , AllComponents(allComponents) - , Backtrace(std::move(backtrace)) + , Context{ std::move(context) } { } @@ -231,8 +230,8 @@ std::string cmInstallGenerator::ConvertToAbsoluteDestination( return result; } -void cmInstallGenerator::CheckAbsoluteDestination( - std::string const& dest, cmLocalGenerator* lg, cmListFileBacktrace const& bt) +void cmInstallGenerator::CheckAbsoluteDestination(std::string const& dest, + cmLocalGenerator* lg) const { if (!cmSystemTools::FileIsFullPath(dest)) { return; @@ -241,7 +240,7 @@ void cmInstallGenerator::CheckAbsoluteDestination( cmDiagnostics::CMD_INSTALL_ABSOLUTE_DESTINATION, cmStrCat("INSTALL command given absolute DESTINATION path (", dest, ").\n"), - bt); + this->Context); } cmInstallGenerator::MessageLevel cmInstallGenerator::SelectMessageLevel( @@ -263,6 +262,14 @@ cmInstallGenerator::MessageLevel cmInstallGenerator::SelectMessageLevel( return MessageDefault; } +cmDiagnosticContext cmInstallGenerator::CaptureContext(cmMakefile const& mf) +{ + cmDiagnosticContext context{ mf.GetBacktrace() }; + context.RecordDiagnostic(cmDiagnostics::CMD_INSTALL_ABSOLUTE_DESTINATION, + mf.GetStateSnapshot()); + return context; +} + std::string cmInstallGenerator::GetDestDirPath(std::string const& file) { // Construct the path of the file on disk after installation on diff --git a/Source/cmInstallGenerator.h b/Source/cmInstallGenerator.h index 9a4b68b591..75634ee60f 100644 --- a/Source/cmInstallGenerator.h +++ b/Source/cmInstallGenerator.h @@ -9,12 +9,13 @@ #include #include +#include "cmDiagnosticContext.h" #include "cmInstallType.h" -#include "cmListFileCache.h" #include "cmScriptGenerator.h" class cmLocalGenerator; class cmMakefile; +class cmListFileBacktrace; /** \class cmInstallGenerator * \brief Support class for generating install scripts. @@ -35,7 +36,7 @@ public: std::vector const& configurations, std::string component, MessageLevel message, bool excludeFromAll, bool allComponents, - cmListFileBacktrace backtrace); + cmDiagnosticContext context); ~cmInstallGenerator() override; cmInstallGenerator(cmInstallGenerator const&) = delete; @@ -56,9 +57,8 @@ public: /** Get the install destination as it should appear in the installation script. */ static std::string ConvertToAbsoluteDestination(std::string const& dest); - static void CheckAbsoluteDestination(std::string const& dest, - cmLocalGenerator* lg, - cmListFileBacktrace const& bt); + void CheckAbsoluteDestination(std::string const& dest, + cmLocalGenerator* lg) const; /** Test if this generator installs something for a given configuration. */ bool InstallsForConfig(std::string const& config); @@ -66,6 +66,13 @@ public: /** Select message level from CMAKE_INSTALL_MESSAGE or 'never'. */ static MessageLevel SelectMessageLevel(cmMakefile* mf, bool never = false); + /** Capture context for generator. */ + static cmDiagnosticContext CaptureContext(cmMakefile const& mf); + static cmDiagnosticContext CaptureContext(cmMakefile const* mf) + { + return cmInstallGenerator::CaptureContext(*mf); + } + virtual bool Compute(cmLocalGenerator*) { return true; } std::string const& GetComponent() const { return this->Component; } @@ -73,7 +80,10 @@ public: bool GetExcludeFromAll() const { return this->ExcludeFromAll; } bool GetAllComponentsFlag() const { return this->AllComponents; } - cmListFileBacktrace const& GetBacktrace() const { return this->Backtrace; } + cmListFileBacktrace const& GetBacktrace() const + { + return this->Context.GetBacktrace(); + } static std::string GetDestDirPath(std::string const& file); @@ -101,5 +111,5 @@ protected: MessageLevel const Message; bool const ExcludeFromAll; bool const AllComponents; - cmListFileBacktrace const Backtrace; + cmDiagnosticContext const Context; }; diff --git a/Source/cmInstallGetRuntimeDependenciesGenerator.cxx b/Source/cmInstallGetRuntimeDependenciesGenerator.cxx index 6e2749876f..c4e16f4587 100644 --- a/Source/cmInstallGetRuntimeDependenciesGenerator.cxx +++ b/Source/cmInstallGetRuntimeDependenciesGenerator.cxx @@ -13,6 +13,7 @@ #include #include +#include "cmDiagnosticContext.h" #include "cmGeneratorExpression.h" #include "cmInstallRuntimeDependencySet.h" #include "cmListFileCache.h" @@ -87,7 +88,7 @@ cmInstallGetRuntimeDependenciesGenerator:: MessageLevel message, bool excludeFromAll, cmListFileBacktrace backtrace, cmPolicies::PolicyStatus policyStatusCMP0207) : cmInstallGenerator("", configurations, "", message, excludeFromAll, false, - std::move(backtrace)) + cmDiagnosticContext{ std::move(backtrace) }) , RuntimeDependencySet(runtimeDependencySet) , Directories(std::move(directories)) , PreIncludeRegexes(std::move(preIncludeRegexes)) diff --git a/Source/cmInstallImportedRuntimeArtifactsGenerator.cxx b/Source/cmInstallImportedRuntimeArtifactsGenerator.cxx index a2ae0ffc17..255e30f255 100644 --- a/Source/cmInstallImportedRuntimeArtifactsGenerator.cxx +++ b/Source/cmInstallImportedRuntimeArtifactsGenerator.cxx @@ -13,7 +13,6 @@ #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" #include "cmInstallType.h" -#include "cmListFileCache.h" #include "cmLocalGenerator.h" #include "cmStateTypes.h" #include "cmStringAlgorithms.h" @@ -35,9 +34,9 @@ cmInstallImportedRuntimeArtifactsGenerator:: std::string filePermissions, std::vector const& configurations, std::string const& component, MessageLevel message, bool excludeFromAll, - bool optional, cmListFileBacktrace backtrace) + bool optional, cmDiagnosticContext context) : cmInstallGenerator(dest, configurations, component, message, - excludeFromAll, false, std::move(backtrace)) + excludeFromAll, false, std::move(context)) , TargetName(std::move(targetName)) , FilePermissions(std::move(filePermissions)) , Optional(optional) diff --git a/Source/cmInstallImportedRuntimeArtifactsGenerator.h b/Source/cmInstallImportedRuntimeArtifactsGenerator.h index 411d472ac1..2920567706 100644 --- a/Source/cmInstallImportedRuntimeArtifactsGenerator.h +++ b/Source/cmInstallImportedRuntimeArtifactsGenerator.h @@ -6,8 +6,8 @@ #include #include +#include "cmDiagnosticContext.h" #include "cmInstallGenerator.h" -#include "cmListFileCache.h" class cmGeneratorTarget; @@ -19,7 +19,7 @@ public: std::string filePermissions, std::vector const& configurations, std::string const& component, MessageLevel message, bool excludeFromAll, - bool optional, cmListFileBacktrace backtrace = cmListFileBacktrace()); + bool optional, cmDiagnosticContext context = {}); ~cmInstallImportedRuntimeArtifactsGenerator() override = default; bool Compute(cmLocalGenerator* lg) override; diff --git a/Source/cmInstallPackageInfoExportGenerator.cxx b/Source/cmInstallPackageInfoExportGenerator.cxx index 55dcbd100f..fe7b77f5c3 100644 --- a/Source/cmInstallPackageInfoExportGenerator.cxx +++ b/Source/cmInstallPackageInfoExportGenerator.cxx @@ -6,9 +6,9 @@ #include +#include "cmDiagnosticContext.h" #include "cmExportInstallFileGenerator.h" #include "cmExportInstallPackageInfoGenerator.h" -#include "cmListFileCache.h" #include "cmPackageInfoArguments.h" class cmExportSet; @@ -17,12 +17,12 @@ cmInstallPackageInfoExportGenerator::cmInstallPackageInfoExportGenerator( cmExportSet* exportSet, std::string destination, std::string filePermissions, std::vector const& configurations, std::string component, MessageLevel message, bool excludeFromAll, cmPackageInfoArguments arguments, - std::string cxxModulesDirectory, cmListFileBacktrace backtrace) + std::string cxxModulesDirectory, cmDiagnosticContext context) : cmInstallExportGenerator( exportSet, std::move(destination), std::move(filePermissions), configurations, std::move(component), message, excludeFromAll, arguments.GetPackageFileName(), arguments.GetNamespace(), - std::move(cxxModulesDirectory), std::move(backtrace)) + std::move(cxxModulesDirectory), std::move(context)) { this->EFGen = cm::make_unique( this, std::move(arguments)); diff --git a/Source/cmInstallPackageInfoExportGenerator.h b/Source/cmInstallPackageInfoExportGenerator.h index 0209f82ee6..b323705fe6 100644 --- a/Source/cmInstallPackageInfoExportGenerator.h +++ b/Source/cmInstallPackageInfoExportGenerator.h @@ -7,8 +7,8 @@ #include "cmInstallExportGenerator.h" +class cmDiagnosticContext; class cmExportSet; -class cmListFileBacktrace; class cmPackageInfoArguments; /** \class cmInstallPackageInfoGenerator @@ -23,7 +23,7 @@ public: std::vector const& configurations, std::string component, MessageLevel message, bool excludeFromAll, cmPackageInfoArguments arguments, std::string cxxModulesDirectory, - cmListFileBacktrace backtrace); + cmDiagnosticContext context); cmInstallPackageInfoExportGenerator( cmInstallPackageInfoExportGenerator const&) = delete; ~cmInstallPackageInfoExportGenerator() override; diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx index 0a808b7bd5..474bbc41a1 100644 --- a/Source/cmInstallProgramsCommand.cxx +++ b/Source/cmInstallProgramsCommand.cxx @@ -99,7 +99,8 @@ static void FinalAction(cmMakefile& makefile, std::string const& dest, cmInstallGenerator::SelectMessageLevel(&makefile); makefile.AddInstallGenerator(cm::make_unique( files, destination, true, no_permissions, no_configurations, no_component, - message, no_exclude_from_all, no_rename, false, makefile.GetBacktrace())); + message, no_exclude_from_all, no_rename, false, + cmInstallGenerator::CaptureContext(makefile))); } /** diff --git a/Source/cmInstallRuntimeDependencySetGenerator.cxx b/Source/cmInstallRuntimeDependencySetGenerator.cxx index 53c3429915..675d2fa3d5 100644 --- a/Source/cmInstallRuntimeDependencySetGenerator.cxx +++ b/Source/cmInstallRuntimeDependencySetGenerator.cxx @@ -7,10 +7,10 @@ #include #include +#include "cmDiagnosticContext.h" #include "cmGeneratorExpression.h" #include "cmInstallGenerator.h" #include "cmInstallType.h" -#include "cmListFileCache.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmMessageType.h" @@ -25,10 +25,10 @@ cmInstallRuntimeDependencySetGenerator::cmInstallRuntimeDependencySetGenerator( char const* rpathPrefix, char const* tmpVarPrefix, std::string destination, std::vector const& configurations, std::string component, std::string permissions, MessageLevel message, bool excludeFromAll, - cmListFileBacktrace backtrace) + cmDiagnosticContext context) : cmInstallGenerator(std::move(destination), configurations, std::move(component), message, excludeFromAll, false, - std::move(backtrace)) + std::move(context)) , Type(type) , DependencySet(dependencySet) , InstallRPaths(std::move(installRPaths)) @@ -68,7 +68,7 @@ void cmInstallRuntimeDependencySetGenerator::GenerateScriptForConfig( MessageType::FATAL_ERROR, "INSTALL_NAME_DIR argument must not evaluate to an " "empty string", - this->Backtrace); + this->Context.GetBacktrace()); return; } if (installNameDir.back() != '/') { diff --git a/Source/cmInstallRuntimeDependencySetGenerator.h b/Source/cmInstallRuntimeDependencySetGenerator.h index 80f4cc328a..ba2f74d9d5 100644 --- a/Source/cmInstallRuntimeDependencySetGenerator.h +++ b/Source/cmInstallRuntimeDependencySetGenerator.h @@ -8,8 +8,8 @@ #include "cmInstallGenerator.h" +class cmDiagnosticContext; class cmInstallRuntimeDependencySet; -class cmListFileBacktrace; class cmLocalGenerator; class cmInstallRuntimeDependencySetGenerator : public cmInstallGenerator @@ -28,7 +28,7 @@ public: char const* rpathPrefix, char const* tmpVarPrefix, std::string destination, std::vector const& configurations, std::string component, std::string permissions, MessageLevel message, bool excludeFromAll, - cmListFileBacktrace backtrace); + cmDiagnosticContext context); bool Compute(cmLocalGenerator* lg) override; diff --git a/Source/cmInstallSbomExportGenerator.cxx b/Source/cmInstallSbomExportGenerator.cxx index 01af7edc53..4072b44be5 100644 --- a/Source/cmInstallSbomExportGenerator.cxx +++ b/Source/cmInstallSbomExportGenerator.cxx @@ -6,9 +6,9 @@ file LICENSE.rst or https://cmake.org/licensing for details. */ #include +#include "cmDiagnosticContext.h" #include "cmExportInstallFileGenerator.h" #include "cmExportInstallSbomGenerator.h" -#include "cmListFileCache.h" #include "cmSbomArguments.h" class cmExportSet; @@ -17,12 +17,12 @@ cmInstallSbomExportGenerator::cmInstallSbomExportGenerator( cmExportSet* exportSet, std::string destination, std::string filePermissions, std::vector const& configurations, std::string component, MessageLevel message, bool excludeFromAll, cmSbomArguments args, - std::string cxxModulesDirectory, cmListFileBacktrace backtrace) + std::string cxxModulesDirectory, cmDiagnosticContext context) : cmInstallExportGenerator( exportSet, std::move(destination), std::move(filePermissions), configurations, std::move(component), message, excludeFromAll, args.GetPackageFileName(), args.GetNamespace(), - std::move(cxxModulesDirectory), std::move(backtrace)) + std::move(cxxModulesDirectory), std::move(context)) { this->EFGen = cm::make_unique(this, args); } diff --git a/Source/cmInstallSbomExportGenerator.h b/Source/cmInstallSbomExportGenerator.h index 23d731814d..eaddc55123 100644 --- a/Source/cmInstallSbomExportGenerator.h +++ b/Source/cmInstallSbomExportGenerator.h @@ -7,8 +7,8 @@ #include "cmInstallExportGenerator.h" +class cmDiagnosticContext; class cmExportSet; -class cmListFileBacktrace; class cmSbomArguments; class cmInstallSbomExportGenerator final : public cmInstallExportGenerator @@ -20,7 +20,7 @@ public: std::string component, MessageLevel message, bool excludeFromAll, cmSbomArguments arguments, std::string cxxModulesDirectory, - cmListFileBacktrace backtrace); + cmDiagnosticContext context); cmInstallSbomExportGenerator(cmInstallSbomExportGenerator const&) = delete; ~cmInstallSbomExportGenerator() override; diff --git a/Source/cmInstallScriptGenerator.cxx b/Source/cmInstallScriptGenerator.cxx index 0070b6095a..133d68ac67 100644 --- a/Source/cmInstallScriptGenerator.cxx +++ b/Source/cmInstallScriptGenerator.cxx @@ -6,6 +6,7 @@ #include #include +#include "cmDiagnosticContext.h" #include "cmDiagnostics.h" #include "cmGeneratorExpression.h" #include "cmLocalGenerator.h" @@ -17,7 +18,7 @@ cmInstallScriptGenerator::cmInstallScriptGenerator( bool excludeFromAll, bool allComponents, cmListFileBacktrace backtrace) : cmInstallGenerator("", std::vector(), component, MessageDefault, excludeFromAll, allComponents, - std::move(backtrace)) + cmDiagnosticContext{ std::move(backtrace) }) , Script(std::move(script)) , Code(code) { diff --git a/Source/cmInstallSubdirectoryGenerator.cxx b/Source/cmInstallSubdirectoryGenerator.cxx index 34de2f6d8b..ce7fdb0328 100644 --- a/Source/cmInstallSubdirectoryGenerator.cxx +++ b/Source/cmInstallSubdirectoryGenerator.cxx @@ -7,6 +7,7 @@ #include #include +#include "cmDiagnosticContext.h" #include "cmListFileCache.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" @@ -18,7 +19,8 @@ cmInstallSubdirectoryGenerator::cmInstallSubdirectoryGenerator( cmMakefile* makefile, std::string binaryDirectory, cmListFileBacktrace backtrace) : cmInstallGenerator("", std::vector(), "", MessageDefault, - false, false, std::move(backtrace)) + false, false, + cmDiagnosticContext{ std::move(backtrace) }) , Makefile(makefile) , BinaryDirectory(std::move(binaryDirectory)) { diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index e38b296142..c84c1e10cb 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -15,11 +15,13 @@ #include #include "cmComputeLinkInformation.h" +#include "cmDiagnosticContext.h" #include "cmDiagnostics.h" #include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" #include "cmInstallType.h" +#include "cmListFileCache.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmMessageType.h" @@ -130,9 +132,9 @@ cmInstallTargetGenerator::cmInstallTargetGenerator( std::string targetName, std::string const& dest, bool implib, std::string filePermissions, std::vector const& configurations, std::string const& component, MessageLevel message, bool excludeFromAll, - bool optional, cmListFileBacktrace backtrace) + bool optional, cmDiagnosticContext context) : cmInstallGenerator(dest, configurations, component, message, - excludeFromAll, false, std::move(backtrace)) + excludeFromAll, false, std::move(context)) , TargetName(std::move(targetName)) , FilePermissions(std::move(filePermissions)) , ImportLibrary(implib) @@ -482,7 +484,7 @@ std::string cmInstallTargetGenerator::GetDestination( cmLocalGenerator* lg = this->Target->GetLocalGenerator(); std::string dest = cmGeneratorExpression::Evaluate(this->Destination, lg, config); - cmInstallGenerator::CheckAbsoluteDestination(dest, lg, this->Backtrace); + this->CheckAbsoluteDestination(dest, lg); return dest; } diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index dd1a596ff4..cb44125419 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -8,9 +8,9 @@ #include #include +#include "cmDiagnosticContext.h" #include "cmInstallGenerator.h" #include "cmInstallType.h" -#include "cmListFileCache.h" class cmGeneratorTarget; @@ -20,12 +20,12 @@ class cmGeneratorTarget; class cmInstallTargetGenerator : public cmInstallGenerator { public: - cmInstallTargetGenerator( - std::string targetName, std::string const& dest, bool implib, - std::string filePermissions, - std::vector const& configurations, - std::string const& component, MessageLevel message, bool excludeFromAll, - bool optional, cmListFileBacktrace backtrace = cmListFileBacktrace()); + cmInstallTargetGenerator(std::string targetName, std::string const& dest, + bool implib, std::string filePermissions, + std::vector const& configurations, + std::string const& component, MessageLevel message, + bool excludeFromAll, bool optional, + cmDiagnosticContext context = {}); ~cmInstallTargetGenerator() override; /** Select the policy for installing shared library linkable name diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake index 5e40e88e27..fefef4698d 100644 --- a/Tests/RunCMake/install/RunCMakeTest.cmake +++ b/Tests/RunCMake/install/RunCMakeTest.cmake @@ -87,9 +87,9 @@ run_cmake_with_options(FILES-AbsoluteDest-error -Werror=install-absolute-destina run_cmake_with_options(FILES-AbsoluteDest-warn -Winstall-absolute-destination) run_cmake_with_options(TARGETS-AbsoluteDest-error -Werror=install-absolute-destination) run_cmake_with_options(TARGETS-AbsoluteDest-warn -Winstall-absolute-destination) -run_cmake_with_options(TARGETS-AbsoluteDest-archive-error -Werror=install-absolute-destination) -run_cmake_with_options(TARGETS-AbsoluteDest-library-error -Werror=install-absolute-destination) -run_cmake_with_options(TARGETS-AbsoluteDest-runtime-error -Werror=install-absolute-destination) +run_cmake(TARGETS-AbsoluteDest-archive-error) +run_cmake(TARGETS-AbsoluteDest-library-error) +run_cmake(TARGETS-AbsoluteDest-runtime-error) run_cmake(EXPORT-Component) run_cmake(EXPORT-FindDependencyExportGate) run_cmake(EXPORT-OldIFace) diff --git a/Tests/RunCMake/install/TARGETS-AbsoluteDest-archive-error.cmake b/Tests/RunCMake/install/TARGETS-AbsoluteDest-archive-error.cmake index 3ecc7e387b..427403d434 100644 --- a/Tests/RunCMake/install/TARGETS-AbsoluteDest-archive-error.cmake +++ b/Tests/RunCMake/install/TARGETS-AbsoluteDest-archive-error.cmake @@ -1,3 +1,4 @@ enable_language(C) add_library(mylib STATIC empty.c) +cmake_diagnostic(SET CMD_INSTALL_ABSOLUTE_DESTINATION SEND_ERROR) install(TARGETS mylib ARCHIVE DESTINATION /absolute/archive) diff --git a/Tests/RunCMake/install/TARGETS-AbsoluteDest-error.cmake b/Tests/RunCMake/install/TARGETS-AbsoluteDest-error.cmake index b16af5c2e6..e2ca4befcd 100644 --- a/Tests/RunCMake/install/TARGETS-AbsoluteDest-error.cmake +++ b/Tests/RunCMake/install/TARGETS-AbsoluteDest-error.cmake @@ -1,12 +1,3 @@ enable_language(C) add_library(mylib STATIC empty.c) - -# FIXME(#27770): This diagnostic is issued at generate time. Currently, the -# install generator doesn't capture the immediate diagnostic state, only the -# top-most state of the current subdirectory, which we cannot affect (because -# this test was include()d. When we fix that, we should test by changing the -# diagnostic action here rather than by -W... in the test CLI arguments. -# cmake_diagnostic(SET CMD_INSTALL_ABSOLUTE_DESTINATION SEND_ERROR) - -cmake_diagnostic(PROMOTE CMD_INSTALL_ABSOLUTE_DESTINATION WARN) install(TARGETS mylib DESTINATION /absolute/path) diff --git a/Tests/RunCMake/install/TARGETS-AbsoluteDest-library-error.cmake b/Tests/RunCMake/install/TARGETS-AbsoluteDest-library-error.cmake index b5be8fdd3e..3885862289 100644 --- a/Tests/RunCMake/install/TARGETS-AbsoluteDest-library-error.cmake +++ b/Tests/RunCMake/install/TARGETS-AbsoluteDest-library-error.cmake @@ -1,3 +1,4 @@ enable_language(C) add_library(mylib MODULE empty.c) +cmake_diagnostic(SET CMD_INSTALL_ABSOLUTE_DESTINATION SEND_ERROR) install(TARGETS mylib LIBRARY DESTINATION /absolute/lib) diff --git a/Tests/RunCMake/install/TARGETS-AbsoluteDest-runtime-error.cmake b/Tests/RunCMake/install/TARGETS-AbsoluteDest-runtime-error.cmake index 638f7fba95..df0547b1bf 100644 --- a/Tests/RunCMake/install/TARGETS-AbsoluteDest-runtime-error.cmake +++ b/Tests/RunCMake/install/TARGETS-AbsoluteDest-runtime-error.cmake @@ -1,3 +1,4 @@ enable_language(C) add_executable(myexe empty.c) +cmake_diagnostic(SET CMD_INSTALL_ABSOLUTE_DESTINATION SEND_ERROR) install(TARGETS myexe RUNTIME DESTINATION /absolute/bin)