mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-07 06:09:52 -06:00
install: Record TARGET mode backtraces internally
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
#include "cmInstallGenerator.h"
|
#include "cmInstallGenerator.h"
|
||||||
#include "cmInstallScriptGenerator.h"
|
#include "cmInstallScriptGenerator.h"
|
||||||
#include "cmInstallTargetGenerator.h"
|
#include "cmInstallTargetGenerator.h"
|
||||||
|
#include "cmListFileCache.h"
|
||||||
#include "cmMakefile.h"
|
#include "cmMakefile.h"
|
||||||
#include "cmPolicies.h"
|
#include "cmPolicies.h"
|
||||||
#include "cmStateTypes.h"
|
#include "cmStateTypes.h"
|
||||||
@@ -32,7 +33,8 @@ class cmExecutionStatus;
|
|||||||
|
|
||||||
static cmInstallTargetGenerator* CreateInstallTargetGenerator(
|
static cmInstallTargetGenerator* CreateInstallTargetGenerator(
|
||||||
cmTarget& target, const cmInstallCommandArguments& args, bool impLib,
|
cmTarget& target, const cmInstallCommandArguments& args, bool impLib,
|
||||||
bool forceOpt = false, bool namelink = false)
|
cmListFileBacktrace const& backtrace, bool forceOpt = false,
|
||||||
|
bool namelink = false)
|
||||||
{
|
{
|
||||||
cmInstallGenerator::MessageLevel message =
|
cmInstallGenerator::MessageLevel message =
|
||||||
cmInstallGenerator::SelectMessageLevel(target.GetMakefile());
|
cmInstallGenerator::SelectMessageLevel(target.GetMakefile());
|
||||||
@@ -42,7 +44,8 @@ static cmInstallTargetGenerator* CreateInstallTargetGenerator(
|
|||||||
return new cmInstallTargetGenerator(
|
return new cmInstallTargetGenerator(
|
||||||
target.GetName(), args.GetDestination().c_str(), impLib,
|
target.GetName(), args.GetDestination().c_str(), impLib,
|
||||||
args.GetPermissions().c_str(), args.GetConfigurations(), component,
|
args.GetPermissions().c_str(), args.GetConfigurations(), component,
|
||||||
message, args.GetExcludeFromAll(), args.GetOptional() || forceOpt);
|
message, args.GetExcludeFromAll(), args.GetOptional() || forceOpt,
|
||||||
|
backtrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
static cmInstallFilesGenerator* CreateInstallFilesGenerator(
|
static cmInstallFilesGenerator* CreateInstallFilesGenerator(
|
||||||
@@ -435,13 +438,13 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
|
|||||||
// This is a DLL platform.
|
// This is a DLL platform.
|
||||||
if (!archiveArgs.GetDestination().empty()) {
|
if (!archiveArgs.GetDestination().empty()) {
|
||||||
// The import library uses the ARCHIVE properties.
|
// The import library uses the ARCHIVE properties.
|
||||||
archiveGenerator =
|
archiveGenerator = CreateInstallTargetGenerator(
|
||||||
CreateInstallTargetGenerator(target, archiveArgs, true);
|
target, archiveArgs, true, this->Makefile->GetBacktrace());
|
||||||
}
|
}
|
||||||
if (!runtimeArgs.GetDestination().empty()) {
|
if (!runtimeArgs.GetDestination().empty()) {
|
||||||
// The DLL uses the RUNTIME properties.
|
// The DLL uses the RUNTIME properties.
|
||||||
runtimeGenerator =
|
runtimeGenerator = CreateInstallTargetGenerator(
|
||||||
CreateInstallTargetGenerator(target, runtimeArgs, false);
|
target, runtimeArgs, false, this->Makefile->GetBacktrace());
|
||||||
}
|
}
|
||||||
if ((archiveGenerator == nullptr) && (runtimeGenerator == nullptr)) {
|
if ((archiveGenerator == nullptr) && (runtimeGenerator == nullptr)) {
|
||||||
this->SetError("Library TARGETS given no DESTINATION!");
|
this->SetError("Library TARGETS given no DESTINATION!");
|
||||||
@@ -459,8 +462,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
|
|||||||
|
|
||||||
// Use the FRAMEWORK properties.
|
// Use the FRAMEWORK properties.
|
||||||
if (!frameworkArgs.GetDestination().empty()) {
|
if (!frameworkArgs.GetDestination().empty()) {
|
||||||
frameworkGenerator =
|
frameworkGenerator = CreateInstallTargetGenerator(
|
||||||
CreateInstallTargetGenerator(target, frameworkArgs, false);
|
target, frameworkArgs, false, this->Makefile->GetBacktrace());
|
||||||
} else {
|
} else {
|
||||||
std::ostringstream e;
|
std::ostringstream e;
|
||||||
e << "TARGETS given no FRAMEWORK DESTINATION for shared library "
|
e << "TARGETS given no FRAMEWORK DESTINATION for shared library "
|
||||||
@@ -473,14 +476,15 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
|
|||||||
// The shared library uses the LIBRARY properties.
|
// The shared library uses the LIBRARY properties.
|
||||||
if (!libraryArgs.GetDestination().empty()) {
|
if (!libraryArgs.GetDestination().empty()) {
|
||||||
if (namelinkMode != cmInstallTargetGenerator::NamelinkModeOnly) {
|
if (namelinkMode != cmInstallTargetGenerator::NamelinkModeOnly) {
|
||||||
libraryGenerator =
|
libraryGenerator = CreateInstallTargetGenerator(
|
||||||
CreateInstallTargetGenerator(target, libraryArgs, false);
|
target, libraryArgs, false, this->Makefile->GetBacktrace());
|
||||||
libraryGenerator->SetNamelinkMode(
|
libraryGenerator->SetNamelinkMode(
|
||||||
cmInstallTargetGenerator::NamelinkModeSkip);
|
cmInstallTargetGenerator::NamelinkModeSkip);
|
||||||
}
|
}
|
||||||
if (namelinkMode != cmInstallTargetGenerator::NamelinkModeSkip) {
|
if (namelinkMode != cmInstallTargetGenerator::NamelinkModeSkip) {
|
||||||
namelinkGenerator = CreateInstallTargetGenerator(
|
namelinkGenerator = CreateInstallTargetGenerator(
|
||||||
target, libraryArgs, false, false, true);
|
target, libraryArgs, false, this->Makefile->GetBacktrace(),
|
||||||
|
false, true);
|
||||||
namelinkGenerator->SetNamelinkMode(
|
namelinkGenerator->SetNamelinkMode(
|
||||||
cmInstallTargetGenerator::NamelinkModeOnly);
|
cmInstallTargetGenerator::NamelinkModeOnly);
|
||||||
}
|
}
|
||||||
@@ -508,8 +512,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
|
|||||||
|
|
||||||
// Use the FRAMEWORK properties.
|
// Use the FRAMEWORK properties.
|
||||||
if (!frameworkArgs.GetDestination().empty()) {
|
if (!frameworkArgs.GetDestination().empty()) {
|
||||||
frameworkGenerator =
|
frameworkGenerator = CreateInstallTargetGenerator(
|
||||||
CreateInstallTargetGenerator(target, frameworkArgs, false);
|
target, frameworkArgs, false, this->Makefile->GetBacktrace());
|
||||||
} else {
|
} else {
|
||||||
std::ostringstream e;
|
std::ostringstream e;
|
||||||
e << "TARGETS given no FRAMEWORK DESTINATION for static library "
|
e << "TARGETS given no FRAMEWORK DESTINATION for static library "
|
||||||
@@ -521,8 +525,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
|
|||||||
} else {
|
} else {
|
||||||
// Static libraries use ARCHIVE properties.
|
// Static libraries use ARCHIVE properties.
|
||||||
if (!archiveArgs.GetDestination().empty()) {
|
if (!archiveArgs.GetDestination().empty()) {
|
||||||
archiveGenerator =
|
archiveGenerator = CreateInstallTargetGenerator(
|
||||||
CreateInstallTargetGenerator(target, archiveArgs, false);
|
target, archiveArgs, false, this->Makefile->GetBacktrace());
|
||||||
} else {
|
} else {
|
||||||
std::ostringstream e;
|
std::ostringstream e;
|
||||||
e << "TARGETS given no ARCHIVE DESTINATION for static library "
|
e << "TARGETS given no ARCHIVE DESTINATION for static library "
|
||||||
@@ -536,8 +540,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
|
|||||||
case cmStateEnums::MODULE_LIBRARY: {
|
case cmStateEnums::MODULE_LIBRARY: {
|
||||||
// Modules use LIBRARY properties.
|
// Modules use LIBRARY properties.
|
||||||
if (!libraryArgs.GetDestination().empty()) {
|
if (!libraryArgs.GetDestination().empty()) {
|
||||||
libraryGenerator =
|
libraryGenerator = CreateInstallTargetGenerator(
|
||||||
CreateInstallTargetGenerator(target, libraryArgs, false);
|
target, libraryArgs, false, this->Makefile->GetBacktrace());
|
||||||
libraryGenerator->SetNamelinkMode(namelinkMode);
|
libraryGenerator->SetNamelinkMode(namelinkMode);
|
||||||
namelinkOnly =
|
namelinkOnly =
|
||||||
(namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly);
|
(namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly);
|
||||||
@@ -563,8 +567,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
objectGenerator =
|
objectGenerator = CreateInstallTargetGenerator(
|
||||||
CreateInstallTargetGenerator(target, objectArgs, false);
|
target, objectArgs, false, this->Makefile->GetBacktrace());
|
||||||
} else {
|
} else {
|
||||||
// Installing an OBJECT library without a destination transforms
|
// Installing an OBJECT library without a destination transforms
|
||||||
// it to an INTERFACE library. It installs no files but can be
|
// it to an INTERFACE library. It installs no files but can be
|
||||||
@@ -575,15 +579,15 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
|
|||||||
if (target.IsAppBundleOnApple()) {
|
if (target.IsAppBundleOnApple()) {
|
||||||
// Application bundles use the BUNDLE properties.
|
// Application bundles use the BUNDLE properties.
|
||||||
if (!bundleArgs.GetDestination().empty()) {
|
if (!bundleArgs.GetDestination().empty()) {
|
||||||
bundleGenerator =
|
bundleGenerator = CreateInstallTargetGenerator(
|
||||||
CreateInstallTargetGenerator(target, bundleArgs, false);
|
target, bundleArgs, false, this->Makefile->GetBacktrace());
|
||||||
} else if (!runtimeArgs.GetDestination().empty()) {
|
} else if (!runtimeArgs.GetDestination().empty()) {
|
||||||
bool failure = false;
|
bool failure = false;
|
||||||
if (this->CheckCMP0006(failure)) {
|
if (this->CheckCMP0006(failure)) {
|
||||||
// For CMake 2.4 compatibility fallback to the RUNTIME
|
// For CMake 2.4 compatibility fallback to the RUNTIME
|
||||||
// properties.
|
// properties.
|
||||||
bundleGenerator =
|
bundleGenerator = CreateInstallTargetGenerator(
|
||||||
CreateInstallTargetGenerator(target, runtimeArgs, false);
|
target, runtimeArgs, false, this->Makefile->GetBacktrace());
|
||||||
} else if (failure) {
|
} else if (failure) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -599,8 +603,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
|
|||||||
} else {
|
} else {
|
||||||
// Executables use the RUNTIME properties.
|
// Executables use the RUNTIME properties.
|
||||||
if (!runtimeArgs.GetDestination().empty()) {
|
if (!runtimeArgs.GetDestination().empty()) {
|
||||||
runtimeGenerator =
|
runtimeGenerator = CreateInstallTargetGenerator(
|
||||||
CreateInstallTargetGenerator(target, runtimeArgs, false);
|
target, runtimeArgs, false, this->Makefile->GetBacktrace());
|
||||||
} else {
|
} else {
|
||||||
std::ostringstream e;
|
std::ostringstream e;
|
||||||
e << "TARGETS given no RUNTIME DESTINATION for executable "
|
e << "TARGETS given no RUNTIME DESTINATION for executable "
|
||||||
@@ -617,8 +621,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
|
|||||||
if (dll_platform && !archiveArgs.GetDestination().empty() &&
|
if (dll_platform && !archiveArgs.GetDestination().empty() &&
|
||||||
target.IsExecutableWithExports()) {
|
target.IsExecutableWithExports()) {
|
||||||
// The import library uses the ARCHIVE properties.
|
// The import library uses the ARCHIVE properties.
|
||||||
archiveGenerator =
|
archiveGenerator = CreateInstallTargetGenerator(
|
||||||
CreateInstallTargetGenerator(target, archiveArgs, true, true);
|
target, archiveArgs, true, this->Makefile->GetBacktrace(), true);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case cmStateEnums::INTERFACE_LIBRARY:
|
case cmStateEnums::INTERFACE_LIBRARY:
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ cmInstallTargetGenerator::cmInstallTargetGenerator(
|
|||||||
const std::string& targetName, const char* dest, bool implib,
|
const std::string& targetName, const char* dest, bool implib,
|
||||||
const char* file_permissions, std::vector<std::string> const& configurations,
|
const char* file_permissions, std::vector<std::string> const& configurations,
|
||||||
const char* component, MessageLevel message, bool exclude_from_all,
|
const char* component, MessageLevel message, bool exclude_from_all,
|
||||||
bool optional)
|
bool optional, cmListFileBacktrace const& backtrace)
|
||||||
: cmInstallGenerator(dest, configurations, component, message,
|
: cmInstallGenerator(dest, configurations, component, message,
|
||||||
exclude_from_all)
|
exclude_from_all)
|
||||||
, TargetName(targetName)
|
, TargetName(targetName)
|
||||||
@@ -32,6 +32,7 @@ cmInstallTargetGenerator::cmInstallTargetGenerator(
|
|||||||
, FilePermissions(file_permissions)
|
, FilePermissions(file_permissions)
|
||||||
, ImportLibrary(implib)
|
, ImportLibrary(implib)
|
||||||
, Optional(optional)
|
, Optional(optional)
|
||||||
|
, Backtrace(backtrace)
|
||||||
{
|
{
|
||||||
this->ActionsPerConfig = true;
|
this->ActionsPerConfig = true;
|
||||||
this->NamelinkMode = NamelinkModeNone;
|
this->NamelinkMode = NamelinkModeNone;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "cmConfigure.h" // IWYU pragma: keep
|
#include "cmConfigure.h" // IWYU pragma: keep
|
||||||
|
|
||||||
#include "cmInstallGenerator.h"
|
#include "cmInstallGenerator.h"
|
||||||
|
#include "cmListFileCache.h"
|
||||||
#include "cmScriptGenerator.h"
|
#include "cmScriptGenerator.h"
|
||||||
|
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
@@ -21,11 +22,12 @@ class cmLocalGenerator;
|
|||||||
class cmInstallTargetGenerator : public cmInstallGenerator
|
class cmInstallTargetGenerator : public cmInstallGenerator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cmInstallTargetGenerator(std::string const& targetName, const char* dest,
|
cmInstallTargetGenerator(
|
||||||
bool implib, const char* file_permissions,
|
std::string const& targetName, const char* dest, bool implib,
|
||||||
std::vector<std::string> const& configurations,
|
const char* file_permissions,
|
||||||
const char* component, MessageLevel message,
|
std::vector<std::string> const& configurations, const char* component,
|
||||||
bool exclude_from_all, bool optional);
|
MessageLevel message, bool exclude_from_all, bool optional,
|
||||||
|
cmListFileBacktrace const& backtrace = cmListFileBacktrace());
|
||||||
~cmInstallTargetGenerator() override;
|
~cmInstallTargetGenerator() override;
|
||||||
|
|
||||||
/** Select the policy for installing shared library linkable name
|
/** Select the policy for installing shared library linkable name
|
||||||
@@ -64,6 +66,8 @@ public:
|
|||||||
|
|
||||||
std::string GetDestination(std::string const& config) const;
|
std::string GetDestination(std::string const& config) const;
|
||||||
|
|
||||||
|
cmListFileBacktrace const& GetBacktrace() const { return this->Backtrace; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void GenerateScript(std::ostream& os) override;
|
void GenerateScript(std::ostream& os) override;
|
||||||
void GenerateScriptForConfig(std::ostream& os, const std::string& config,
|
void GenerateScriptForConfig(std::ostream& os, const std::string& config,
|
||||||
@@ -108,6 +112,7 @@ protected:
|
|||||||
NamelinkModeType NamelinkMode;
|
NamelinkModeType NamelinkMode;
|
||||||
bool ImportLibrary;
|
bool ImportLibrary;
|
||||||
bool Optional;
|
bool Optional;
|
||||||
|
cmListFileBacktrace Backtrace;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user