CMP0026: Remove support for OLD behavior

This commit is contained in:
Brad King 2024-11-22 16:56:15 -05:00
parent 796cf2d8eb
commit f8bc8780c1
52 changed files with 54 additions and 448 deletions

View File

@ -1,6 +1,9 @@
CMP0026 CMP0026
------- -------
.. |REMOVED_IN_CMAKE_VERSION| replace:: 4.0
.. include:: REMOVED_PROLOGUE.txt
Disallow use of the LOCATION property for build targets. Disallow use of the LOCATION property for build targets.
CMake 2.8.12 and lower allowed reading the :prop_tgt:`LOCATION` target CMake 2.8.12 and lower allowed reading the :prop_tgt:`LOCATION` target
@ -23,7 +26,5 @@ properties from build-targets. The ``NEW`` behavior for this policy is to
not to allow reading the :prop_tgt:`LOCATION` properties from build-targets. not to allow reading the :prop_tgt:`LOCATION` properties from build-targets.
.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.0 .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.0
.. |WARNS_OR_DOES_NOT_WARN| replace:: warns .. |WARNED_OR_DID_NOT_WARN| replace:: warned
.. include:: STANDARD_ADVICE.txt .. include:: REMOVED_EPILOGUE.txt
.. include:: DEPRECATED.txt

View File

@ -67,15 +67,7 @@ cmValue cmTargetPropertyComputer::GetSources<cmGeneratorTarget>(
template <> template <>
const std::string& const std::string&
cmTargetPropertyComputer::ComputeLocationForBuild<cmGeneratorTarget>( cmTargetPropertyComputer::ImportedLocation<cmGeneratorTarget>(
cmGeneratorTarget const* tgt)
{
return tgt->GetLocation("");
}
template <>
const std::string&
cmTargetPropertyComputer::ComputeLocation<cmGeneratorTarget>(
cmGeneratorTarget const* tgt, const std::string& config) cmGeneratorTarget const* tgt, const std::string& config)
{ {
return tgt->GetLocation(config); return tgt->GetLocation(config);
@ -4202,9 +4194,7 @@ void cmGeneratorTarget::ReportPropertyOrigin(
bool debugOrigin = !this->DebugCompatiblePropertiesDone[p] && bool debugOrigin = !this->DebugCompatiblePropertiesDone[p] &&
cm::contains(debugProperties, p); cm::contains(debugProperties, p);
if (this->GlobalGenerator->GetConfigureDoneCMP0026()) { this->DebugCompatiblePropertiesDone[p] = true;
this->DebugCompatiblePropertiesDone[p] = true;
}
if (!debugOrigin) { if (!debugOrigin) {
return; return;
} }
@ -4709,14 +4699,15 @@ bool cmGeneratorTarget::GetConfigCommonSourceFilesForXcode(
return true; return true;
} }
void cmGeneratorTarget::GetObjectLibrariesCMP0026( void cmGeneratorTarget::GetObjectLibrariesInSources(
std::vector<cmGeneratorTarget*>& objlibs) const std::vector<cmGeneratorTarget*>& objlibs) const
{ {
// At configure-time, this method can be called as part of getting the // FIXME: This searches SOURCES for TARGET_OBJECTS for backwards
// LOCATION property or to export() a file to be include()d. However // compatibility with the OLD behavior of CMP0026 since this
// there is no cmGeneratorTarget at configure-time, so search the SOURCES // could be called at configure time. CMP0026 has been removed,
// for TARGET_OBJECTS instead for backwards compatibility with OLD // so this should now be called only at generate time.
// behavior of CMP0026 only. // Therefore we should be able to improve the implementation
// with generate-time information.
cmBTStringRange rng = this->Target->GetSourceEntries(); cmBTStringRange rng = this->Target->GetSourceEntries();
for (auto const& entry : rng) { for (auto const& entry : rng) {
cmList files{ entry.Value }; cmList files{ entry.Value };
@ -4794,16 +4785,8 @@ void cmGeneratorTarget::GetLanguages(std::set<std::string>& languages,
} }
} }
std::set<cmGeneratorTarget const*> objectLibraries; std::set<cmGeneratorTarget const*> objectLibraries =
if (!this->GlobalGenerator->GetConfigureDoneCMP0026()) { this->GetSourceObjectLibraries(config);
std::vector<cmGeneratorTarget*> objectTargets;
this->GetObjectLibrariesCMP0026(objectTargets);
for (cmGeneratorTarget* gt : objectTargets) {
objectLibraries.insert(gt);
}
} else {
objectLibraries = this->GetSourceObjectLibraries(config);
}
for (cmGeneratorTarget const* objLib : objectLibraries) { for (cmGeneratorTarget const* objLib : objectLibraries) {
objLib->GetLanguages(languages, config); objLib->GetLanguages(languages, config);
} }

View File

@ -489,7 +489,7 @@ public:
bool IsDotNetSdkTarget() const; bool IsDotNetSdkTarget() const;
void GetObjectLibrariesCMP0026( void GetObjectLibrariesInSources(
std::vector<cmGeneratorTarget*>& objlibs) const; std::vector<cmGeneratorTarget*>& objlibs) const;
std::string GetFullNameImported(const std::string& config, std::string GetFullNameImported(const std::string& config,

View File

@ -247,9 +247,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetIncludeDirectories(
bool debugIncludes = !this->DebugIncludesDone && bool debugIncludes = !this->DebugIncludesDone &&
cm::contains(debugProperties, "INCLUDE_DIRECTORIES"); cm::contains(debugProperties, "INCLUDE_DIRECTORIES");
if (this->GlobalGenerator->GetConfigureDoneCMP0026()) { this->DebugIncludesDone = true;
this->DebugIncludesDone = true;
}
EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries(
this, config, lang, &dagChecker, this->IncludeDirectoriesEntries); this, config, lang, &dagChecker, this->IncludeDirectoriesEntries);

View File

@ -15,7 +15,6 @@
#include "cmEvaluatedTargetProperty.h" #include "cmEvaluatedTargetProperty.h"
#include "cmGeneratorExpressionDAGChecker.h" #include "cmGeneratorExpressionDAGChecker.h"
#include "cmGlobalGenerator.h"
#include "cmLinkItem.h" #include "cmLinkItem.h"
#include "cmList.h" #include "cmList.h"
#include "cmListFileCache.h" #include "cmListFileCache.h"
@ -131,9 +130,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetLinkDirectories(
bool debugDirectories = !this->DebugLinkDirectoriesDone && bool debugDirectories = !this->DebugLinkDirectoriesDone &&
cm::contains(debugProperties, "LINK_DIRECTORIES"); cm::contains(debugProperties, "LINK_DIRECTORIES");
if (this->GlobalGenerator->GetConfigureDoneCMP0026()) { this->DebugLinkDirectoriesDone = true;
this->DebugLinkDirectoriesDone = true;
}
EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries(
this, config, language, &dagChecker, this->LinkDirectoriesEntries); this, config, language, &dagChecker, this->LinkDirectoriesEntries);

View File

@ -21,7 +21,6 @@
#include "cmEvaluatedTargetProperty.h" #include "cmEvaluatedTargetProperty.h"
#include "cmGeneratorExpressionDAGChecker.h" #include "cmGeneratorExpressionDAGChecker.h"
#include "cmGlobalGenerator.h"
#include "cmList.h" #include "cmList.h"
#include "cmListFileCache.h" #include "cmListFileCache.h"
#include "cmLocalGenerator.h" #include "cmLocalGenerator.h"
@ -241,9 +240,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileOptions(
bool debugOptions = !this->DebugCompileOptionsDone && bool debugOptions = !this->DebugCompileOptionsDone &&
cm::contains(debugProperties, "COMPILE_OPTIONS"); cm::contains(debugProperties, "COMPILE_OPTIONS");
if (this->GlobalGenerator->GetConfigureDoneCMP0026()) { this->DebugCompileOptionsDone = true;
this->DebugCompileOptionsDone = true;
}
EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries(
this, config, language, &dagChecker, this->CompileOptionsEntries); this, config, language, &dagChecker, this->CompileOptionsEntries);
@ -282,9 +279,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileFeatures(
bool debugFeatures = !this->DebugCompileFeaturesDone && bool debugFeatures = !this->DebugCompileFeaturesDone &&
cm::contains(debugProperties, "COMPILE_FEATURES"); cm::contains(debugProperties, "COMPILE_FEATURES");
if (this->GlobalGenerator->GetConfigureDoneCMP0026()) { this->DebugCompileFeaturesDone = true;
this->DebugCompileFeaturesDone = true;
}
EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries(
this, config, std::string(), &dagChecker, this->CompileFeaturesEntries); this, config, std::string(), &dagChecker, this->CompileFeaturesEntries);
@ -333,9 +328,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileDefinitions(
bool debugDefines = !this->DebugCompileDefinitionsDone && bool debugDefines = !this->DebugCompileDefinitionsDone &&
cm::contains(debugProperties, "COMPILE_DEFINITIONS"); cm::contains(debugProperties, "COMPILE_DEFINITIONS");
if (this->GlobalGenerator->GetConfigureDoneCMP0026()) { this->DebugCompileDefinitionsDone = true;
this->DebugCompileDefinitionsDone = true;
}
EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries(
this, config, language, &dagChecker, this->CompileDefinitionsEntries); this, config, language, &dagChecker, this->CompileDefinitionsEntries);
@ -397,9 +390,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetPrecompileHeaders(
std::find(debugProperties.begin(), debugProperties.end(), std::find(debugProperties.begin(), debugProperties.end(),
"PRECOMPILE_HEADERS") != debugProperties.end(); "PRECOMPILE_HEADERS") != debugProperties.end();
if (this->GlobalGenerator->GetConfigureDoneCMP0026()) { this->DebugPrecompileHeadersDone = true;
this->DebugPrecompileHeadersDone = true;
}
EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries(
this, config, language, &dagChecker, this->PrecompileHeadersEntries); this, config, language, &dagChecker, this->PrecompileHeadersEntries);
@ -454,9 +445,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetLinkOptions(
bool debugOptions = !this->DebugLinkOptionsDone && bool debugOptions = !this->DebugLinkOptionsDone &&
cm::contains(debugProperties, "LINK_OPTIONS"); cm::contains(debugProperties, "LINK_OPTIONS");
if (this->GlobalGenerator->GetConfigureDoneCMP0026()) { this->DebugLinkOptionsDone = true;
this->DebugLinkOptionsDone = true;
}
EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries( EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries(
this, config, language, &dagChecker, this->LinkOptionsEntries); this, config, language, &dagChecker, this->LinkOptionsEntries);

View File

@ -37,7 +37,6 @@
#include "cmSourceFileLocation.h" #include "cmSourceFileLocation.h"
#include "cmSourceGroup.h" #include "cmSourceGroup.h"
#include "cmStateTypes.h" #include "cmStateTypes.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmTarget.h" #include "cmTarget.h"
#include "cmValue.h" #include "cmValue.h"
@ -234,35 +233,12 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetSourceFilePaths(
{ {
std::vector<BT<std::string>> files; std::vector<BT<std::string>> files;
if (!this->LocalGenerator->GetGlobalGenerator()->GetConfigureDoneCMP0026()) {
// At configure-time, this method can be called as part of getting the
// LOCATION property or to export() a file to be include()d. However
// there is no cmGeneratorTarget at configure-time, so search the SOURCES
// for TARGET_OBJECTS instead for backwards compatibility with OLD
// behavior of CMP0026 only.
cmBTStringRange sourceEntries = this->Target->GetSourceEntries();
for (auto const& entry : sourceEntries) {
cmList items{ entry.Value };
for (auto const& item : items) {
if (cmHasLiteralPrefix(item, "$<TARGET_OBJECTS:") &&
item.back() == '>') {
continue;
}
files.emplace_back(item);
}
}
return files;
}
cmList debugProperties{ this->Makefile->GetDefinition( cmList debugProperties{ this->Makefile->GetDefinition(
"CMAKE_DEBUG_TARGET_PROPERTIES") }; "CMAKE_DEBUG_TARGET_PROPERTIES") };
bool debugSources = bool debugSources =
!this->DebugSourcesDone && cm::contains(debugProperties, "SOURCES"); !this->DebugSourcesDone && cm::contains(debugProperties, "SOURCES");
if (this->LocalGenerator->GetGlobalGenerator()->GetConfigureDoneCMP0026()) { this->DebugSourcesDone = true;
this->DebugSourcesDone = true;
}
cmGeneratorExpressionDAGChecker dagChecker(this, "SOURCES", nullptr, nullptr, cmGeneratorExpressionDAGChecker dagChecker(this, "SOURCES", nullptr, nullptr,
this->LocalGenerator, config); this->LocalGenerator, config);
@ -326,24 +302,6 @@ std::vector<BT<cmSourceFile*>> cmGeneratorTarget::GetSourceFiles(
std::string const& config) const std::string const& config) const
{ {
std::vector<BT<cmSourceFile*>> files; std::vector<BT<cmSourceFile*>> files;
if (!this->GlobalGenerator->GetConfigureDoneCMP0026()) {
// Since we are still configuring not all sources may exist yet,
// so we need to avoid full source classification because that
// requires the absolute paths to all sources to be determined.
// Since this is only for compatibility with old policies that
// projects should not depend on anymore, just compute the files
// without memoizing them.
std::vector<BT<std::string>> srcs = this->GetSourceFilePaths(config);
std::set<cmSourceFile*> emitted;
for (BT<std::string> const& s : srcs) {
cmSourceFile* sf = this->Makefile->GetOrCreateSource(s.Value);
if (emitted.insert(sf).second) {
files.emplace_back(sf, s.Backtrace);
}
}
return files;
}
KindedSources const& kinded = this->GetKindedSources(config); KindedSources const& kinded = this->GetKindedSources(config);
files.reserve(kinded.Sources.size()); files.reserve(kinded.Sources.size());
for (SourceAndKind const& si : kinded.Sources) { for (SourceAndKind const& si : kinded.Sources) {

View File

@ -129,7 +129,6 @@ cmGlobalGenerator::cmGlobalGenerator(cmake* cm)
this->CurrentConfigureMakefile = nullptr; this->CurrentConfigureMakefile = nullptr;
this->TryCompileOuterMakefile = nullptr; this->TryCompileOuterMakefile = nullptr;
this->ConfigureDoneCMP0026 = false;
this->FirstTimeProgress = 0.0f; this->FirstTimeProgress = 0.0f;
cm->GetState()->SetIsGeneratorMultiConfig(false); cm->GetState()->SetIsGeneratorMultiConfig(false);
@ -1340,12 +1339,9 @@ void cmGlobalGenerator::Configure()
} }
// now do it // now do it
this->ConfigureDoneCMP0026 = false;
dirMf->Configure(); dirMf->Configure();
dirMf->EnforceDirectoryLevelRules(); dirMf->EnforceDirectoryLevelRules();
this->ConfigureDoneCMP0026 = true;
// Put a copy of each global target in every directory. // Put a copy of each global target in every directory.
{ {
std::vector<GlobalTargetInfo> globalTargets; std::vector<GlobalTargetInfo> globalTargets;
@ -1371,7 +1367,7 @@ void cmGlobalGenerator::CreateGenerationObjects(TargetTypes targetTypes)
{ {
this->CreateLocalGenerators(); this->CreateLocalGenerators();
// Commit side effects only if we are actually generating // Commit side effects only if we are actually generating
if (this->GetConfigureDoneCMP0026()) { if (targetTypes == TargetTypes::AllTargets) {
this->CheckTargetProperties(); this->CheckTargetProperties();
} }
this->CreateGeneratorTargets(targetTypes); this->CreateGeneratorTargets(targetTypes);

View File

@ -639,8 +639,6 @@ public:
cmFileLockPool& GetFileLockPool() { return this->FileLockPool; } cmFileLockPool& GetFileLockPool() { return this->FileLockPool; }
#endif #endif
bool GetConfigureDoneCMP0026() const { return this->ConfigureDoneCMP0026; }
std::string MakeSilentFlag; std::string MakeSilentFlag;
size_t RecursionDepth = 0; size_t RecursionDepth = 0;
@ -941,6 +939,5 @@ protected:
bool ForceUnixPaths; bool ForceUnixPaths;
bool ToolSupportsColor; bool ToolSupportsColor;
bool InstallTargetEnabled; bool InstallTargetEnabled;
bool ConfigureDoneCMP0026;
bool AllowGlobalTargetCodegen; bool AllowGlobalTargetCodegen;
}; };

View File

@ -4910,7 +4910,7 @@ void cmGlobalXCodeGenerator::CreateXCodeDependHackMakefile(
} }
std::vector<cmGeneratorTarget*> objlibs; std::vector<cmGeneratorTarget*> objlibs;
gt->GetObjectLibrariesCMP0026(objlibs); gt->GetObjectLibrariesInSources(objlibs);
for (auto* objLib : objlibs) { for (auto* objLib : objlibs) {
makefileStream << this->PostBuildMakeTarget(objLib->GetName(), makefileStream << this->PostBuildMakeTarget(objLib->GetName(),
configName) configName)

View File

@ -121,7 +121,7 @@ void cmLinkItemGraphVisitor::GetDependencies(cmGeneratorTarget const& target,
} }
std::vector<cmGeneratorTarget*> objectLibraries; std::vector<cmGeneratorTarget*> objectLibraries;
target.GetObjectLibrariesCMP0026(objectLibraries); target.GetObjectLibrariesInSources(objectLibraries);
for (auto const& lib : objectLibraries) { for (auto const& lib : objectLibraries) {
auto const& name = lib->GetName(); auto const& name = lib->GetName();
if (dependencies.find(name) == dependencies.cend()) { if (dependencies.find(name) == dependencies.cend()) {

View File

@ -88,7 +88,7 @@ class cmMakefile;
SELECT(POLICY, CMP0025, "Compiler id for Apple Clang is now AppleClang.", \ SELECT(POLICY, CMP0025, "Compiler id for Apple Clang is now AppleClang.", \
3, 0, 0, NEW) \ 3, 0, 0, NEW) \
SELECT(POLICY, CMP0026, "Disallow use of the LOCATION target property.", 3, \ SELECT(POLICY, CMP0026, "Disallow use of the LOCATION target property.", 3, \
0, 0, WARN) \ 0, 0, NEW) \
SELECT(POLICY, CMP0027, \ SELECT(POLICY, CMP0027, \
"Conditionally linked imported targets with missing include " \ "Conditionally linked imported targets with missing include " \
"directories.", \ "directories.", \

View File

@ -23,7 +23,6 @@
#include "cmFileSet.h" #include "cmFileSet.h"
#include "cmFindPackageStack.h" #include "cmFindPackageStack.h"
#include "cmGeneratorExpression.h" #include "cmGeneratorExpression.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h" #include "cmGlobalGenerator.h"
#include "cmList.h" #include "cmList.h"
#include "cmListFileCache.h" #include "cmListFileCache.h"
@ -46,41 +45,12 @@
#include "cmake.h" #include "cmake.h"
template <> template <>
const std::string& cmTargetPropertyComputer::ComputeLocationForBuild<cmTarget>( const std::string& cmTargetPropertyComputer::ImportedLocation<cmTarget>(
cmTarget const* tgt)
{
static std::string loc;
if (tgt->IsImported()) {
loc = tgt->ImportedGetFullPath("", cmStateEnums::RuntimeBinaryArtifact);
return loc;
}
cmGlobalGenerator* gg = tgt->GetGlobalGenerator();
if (!gg->GetConfigureDoneCMP0026()) {
gg->CreateGenerationObjects();
}
cmGeneratorTarget* gt = gg->FindGeneratorTarget(tgt->GetName());
loc = gt->GetLocationForBuild();
return loc;
}
template <>
const std::string& cmTargetPropertyComputer::ComputeLocation<cmTarget>(
cmTarget const* tgt, const std::string& config) cmTarget const* tgt, const std::string& config)
{ {
static std::string loc; static std::string loc;
if (tgt->IsImported()) { assert(tgt->IsImported());
loc = loc = tgt->ImportedGetFullPath(config, cmStateEnums::RuntimeBinaryArtifact);
tgt->ImportedGetFullPath(config, cmStateEnums::RuntimeBinaryArtifact);
return loc;
}
cmGlobalGenerator* gg = tgt->GetGlobalGenerator();
if (!gg->GetConfigureDoneCMP0026()) {
gg->CreateGenerationObjects();
}
cmGeneratorTarget* gt = gg->FindGeneratorTarget(tgt->GetName());
loc = gt->GetFullPath(config, cmStateEnums::RuntimeBinaryArtifact);
return loc; return loc;
} }

View File

@ -3,39 +3,17 @@
#include "cmTargetPropertyComputer.h" #include "cmTargetPropertyComputer.h"
#include <sstream>
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmMessageType.h" #include "cmMessageType.h"
#include "cmPolicies.h"
bool cmTargetPropertyComputer::HandleLocationPropertyPolicy( void cmTargetPropertyComputer::IssueLocationPropertyError(
std::string const& tgtName, cmMakefile const& mf) std::string const& tgtName, cmMakefile const& mf)
{ {
std::ostringstream e; mf.IssueMessage(
const char* modal = nullptr; MessageType::FATAL_ERROR,
MessageType messageType = MessageType::AUTHOR_WARNING; cmStrCat(
switch (mf.GetPolicyStatus(cmPolicies::CMP0026)) { "The LOCATION property may not be read from target \"", tgtName,
case cmPolicies::WARN: "\". Use the target name directly with "
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0026) << "\n"; "add_custom_command, or use the generator expression $<TARGET_FILE>, "
modal = "should"; "as appropriate.\n"));
CM_FALLTHROUGH;
case cmPolicies::OLD:
break;
case cmPolicies::NEW:
modal = "may";
messageType = MessageType::FATAL_ERROR;
break;
}
if (modal) {
e << "The LOCATION property " << modal << " not be read from target \""
<< tgtName
<< "\". Use the target name directly with "
"add_custom_command, or use the generator expression $<TARGET_FILE>, "
"as appropriate.\n";
mf.IssueMessage(messageType, e.str());
}
return messageType != MessageType::FATAL_ERROR;
} }

View File

@ -33,14 +33,12 @@ public:
} }
private: private:
static bool HandleLocationPropertyPolicy(std::string const& tgtName, static void IssueLocationPropertyError(std::string const& tgtName,
cmMakefile const& mf); cmMakefile const& mf);
template <typename Target> template <typename Target>
static const std::string& ComputeLocationForBuild(Target const* tgt); static const std::string& ImportedLocation(Target const* tgt,
template <typename Target> std::string const& config);
static const std::string& ComputeLocation(Target const* tgt,
std::string const& config);
template <typename Target> template <typename Target>
static cmValue GetLocation(Target const* tgt, std::string const& prop, static cmValue GetLocation(Target const* tgt, std::string const& prop,
@ -56,21 +54,21 @@ private:
tgt->GetType() == cmStateEnums::UNKNOWN_LIBRARY) { tgt->GetType() == cmStateEnums::UNKNOWN_LIBRARY) {
static const std::string propLOCATION = "LOCATION"; static const std::string propLOCATION = "LOCATION";
if (prop == propLOCATION) { if (prop == propLOCATION) {
if (!tgt->IsImported() && if (!tgt->IsImported()) {
!HandleLocationPropertyPolicy(tgt->GetName(), mf)) { IssueLocationPropertyError(tgt->GetName(), mf);
return nullptr; return nullptr;
} }
return cmValue(ComputeLocationForBuild(tgt)); return cmValue(ImportedLocation(tgt, std::string()));
} }
// Support "LOCATION_<CONFIG>". // Support "LOCATION_<CONFIG>".
if (cmHasLiteralPrefix(prop, "LOCATION_")) { if (cmHasLiteralPrefix(prop, "LOCATION_")) {
if (!tgt->IsImported() && if (!tgt->IsImported()) {
!HandleLocationPropertyPolicy(tgt->GetName(), mf)) { IssueLocationPropertyError(tgt->GetName(), mf);
return nullptr; return nullptr;
} }
std::string configName = prop.substr(9); std::string configName = prop.substr(9);
return cmValue(ComputeLocation(tgt, configName)); return cmValue(ImportedLocation(tgt, configName));
} }
// Support "<CONFIG>_LOCATION". // Support "<CONFIG>_LOCATION".
@ -78,11 +76,11 @@ private:
!cmHasLiteralPrefix(prop, "XCODE_ATTRIBUTE_")) { !cmHasLiteralPrefix(prop, "XCODE_ATTRIBUTE_")) {
std::string configName(prop.c_str(), prop.size() - 9); std::string configName(prop.c_str(), prop.size() - 9);
if (configName != "IMPORTED") { if (configName != "IMPORTED") {
if (!tgt->IsImported() && if (!tgt->IsImported()) {
!HandleLocationPropertyPolicy(tgt->GetName(), mf)) { IssueLocationPropertyError(tgt->GetName(), mf);
return nullptr; return nullptr;
} }
return cmValue(ComputeLocation(tgt, configName)); return cmValue(ImportedLocation(tgt, configName));
} }
} }
} }

View File

@ -1,10 +0,0 @@
^CMake Deprecation Warning at CMP0026-CONFIG-LOCATION-OLD.cmake:[0-9]+ \(cmake_policy\):
The OLD behavior for policy CMP0026 will be removed from a future version
of CMake.
The cmake-policies\(7\) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)$

View File

@ -1,7 +0,0 @@
enable_language(CXX)
cmake_policy(SET CMP0026 OLD)
add_library(somelib empty.cpp)
get_target_property(_loc somelib Debug_LOCATION)

View File

@ -1,12 +0,0 @@
CMake Warning \(dev\) at CMP0026-CONFIG-LOCATION-WARN.cmake:5 \(get_target_property\):
Policy CMP0026 is not set: Disallow use of the LOCATION target property.
Run "cmake --help-policy CMP0026" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
The LOCATION property should not be read from target "somelib". Use the
target name directly with add_custom_command, or use the generator
expression \$<TARGET_FILE>, as appropriate.
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.

View File

@ -1,5 +0,0 @@
enable_language(CXX)
add_library(somelib empty.cpp)
get_target_property(_loc somelib Debug_LOCATION)

View File

@ -1,10 +0,0 @@
^CMake Deprecation Warning at CMP0026-LOCATION-CONFIG-OLD.cmake:[0-9]+ \(cmake_policy\):
The OLD behavior for policy CMP0026 will be removed from a future version
of CMake.
The cmake-policies\(7\) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)$

View File

@ -1,7 +0,0 @@
enable_language(CXX)
cmake_policy(SET CMP0026 OLD)
add_library(somelib empty.cpp)
get_target_property(_loc somelib LOCATION_Debug)

View File

@ -1,12 +0,0 @@
CMake Warning \(dev\) at CMP0026-LOCATION-CONFIG-WARN.cmake:5 \(get_target_property\):
Policy CMP0026 is not set: Disallow use of the LOCATION target property.
Run "cmake --help-policy CMP0026" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
The LOCATION property should not be read from target "somelib". Use the
target name directly with add_custom_command, or use the generator
expression \$<TARGET_FILE>, as appropriate.
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.

View File

@ -1,5 +0,0 @@
enable_language(CXX)
add_library(somelib empty.cpp)
get_target_property(_loc somelib LOCATION_Debug)

View File

@ -1,10 +0,0 @@
^CMake Deprecation Warning at CMP0026-OLD.cmake:[0-9]+ \(cmake_policy\):
The OLD behavior for policy CMP0026 will be removed from a future version
of CMake.
The cmake-policies\(7\) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)$

View File

@ -1,12 +0,0 @@
enable_language(CXX)
cmake_policy(SET CMP0026 OLD)
set(out ${CMAKE_CURRENT_BINARY_DIR}/out.txt)
add_library(somelib empty.cpp ${out})
get_target_property(_loc somelib LOCATION)
file(WRITE "${out}"
"source file written by project code after getting target LOCATION\n"
)

View File

@ -1 +0,0 @@
add_library(otherlib ../empty.cpp)

View File

@ -1,25 +0,0 @@
CMake Warning \(dev\) at CMP0026-WARN.cmake:5 \(get_target_property\):
Policy CMP0026 is not set: Disallow use of the LOCATION target property.
Run "cmake --help-policy CMP0026" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
The LOCATION property should not be read from target "somelib". Use the
target name directly with add_custom_command, or use the generator
expression \$<TARGET_FILE>, as appropriate.
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
+
CMake Warning \(dev\) at CMP0026-WARN.cmake:8 \(get_target_property\):
Policy CMP0026 is not set: Disallow use of the LOCATION target property.
Run "cmake --help-policy CMP0026" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
The LOCATION property should not be read from target "otherlib". Use the
target name directly with add_custom_command, or use the generator
expression \$<TARGET_FILE>, as appropriate.
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.

View File

@ -1,8 +0,0 @@
enable_language(CXX)
add_library(somelib empty.cpp)
get_target_property(_loc somelib LOCATION)
add_subdirectory(CMP0026-WARN-Dir)
get_target_property(_loc otherlib LOCATION)

View File

@ -1,3 +1,3 @@
cmake_minimum_required(VERSION 2.8.12) cmake_minimum_required(VERSION 3.10)
project(${RunCMake_TEST} NONE) project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake) include(${RunCMake_TEST}.cmake)

View File

@ -1,12 +0,0 @@
CMake Warning \(dev\) at LOCATION-and-TARGET_OBJECTS.cmake:[0-9]+ \(get_target_property\):
Policy CMP0026 is not set: Disallow use of the LOCATION target property.
Run "cmake --help-policy CMP0026" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
The LOCATION property should not be read from target "bar". Use the target
name directly with add_custom_command, or use the generator expression
\$<TARGET_FILE>, as appropriate.
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.

View File

@ -1,6 +0,0 @@
cmake_policy(SET CMP0118 NEW)
enable_language(CXX)
add_library(foo OBJECT empty.cpp)
add_executable(bar $<TARGET_OBJECTS:foo>)
get_target_property(location bar LOCATION)

View File

@ -1,12 +0,0 @@
CMake Warning \(dev\) at ObjlibNotDefined.cmake:[0-9]+ \(get_target_property\):
Policy CMP0026 is not set: Disallow use of the LOCATION target property.
Run "cmake --help-policy CMP0026" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
The LOCATION property should not be read from target "objlibuser". Use the
target name directly with add_custom_command, or use the generator
expression \$<TARGET_FILE>, as appropriate.
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.

View File

@ -1,13 +0,0 @@
enable_language(CXX)
add_executable(objlibuser
empty.cpp
$<TARGET_OBJECTS:bar>
)
get_target_property(_location objlibuser LOCATION)
add_library(bar OBJECT
empty.cpp
)

View File

@ -1,16 +1,6 @@
include(RunCMake) include(RunCMake)
set(RunCMake_IGNORE_POLICY_VERSION_DEPRECATION ON)
run_cmake(CMP0026-WARN)
run_cmake(CMP0026-OLD)
run_cmake(CMP0026-NEW) run_cmake(CMP0026-NEW)
run_cmake(CMP0026-IMPORTED) run_cmake(CMP0026-IMPORTED)
run_cmake(CMP0026-CONFIG-LOCATION-NEW) run_cmake(CMP0026-CONFIG-LOCATION-NEW)
run_cmake(CMP0026-CONFIG-LOCATION-OLD)
run_cmake(CMP0026-CONFIG-LOCATION-WARN)
run_cmake(CMP0026-LOCATION-CONFIG-NEW) run_cmake(CMP0026-LOCATION-CONFIG-NEW)
run_cmake(CMP0026-LOCATION-CONFIG-OLD)
run_cmake(CMP0026-LOCATION-CONFIG-WARN)
run_cmake(ObjlibNotDefined)
run_cmake(LOCATION-and-TARGET_OBJECTS)
run_cmake(clear-cached-information)

View File

@ -1,2 +0,0 @@
add_executable(Hello ${CMAKE_CURRENT_BINARY_DIR}/main.c)

View File

@ -1,10 +0,0 @@
^CMake Deprecation Warning at clear-cached-information.cmake:[0-9]+ \(cmake_policy\):
The OLD behavior for policy CMP0026 will be removed from a future version
of CMake.
The cmake-policies\(7\) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)$

View File

@ -1,14 +0,0 @@
cmake_policy(SET CMP0118 NEW)
enable_language(C)
cmake_policy(SET CMP0026 OLD)
add_subdirectory(clear-cached-information-dir)
# Critical: this needs to happen in root CMakeLists.txt and not inside
# the subdir.
get_target_property(mypath Hello LOCATION)
# Now we create the file later, so you can see, ultimately no error should
# happen e.g. during generate phase:
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/clear-cached-information-dir/main.c)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/clear-cached-information-dir/main.c PROPERTIES GENERATED TRUE)

View File

@ -1,6 +1,3 @@
cmake_minimum_required(VERSION 3.17) cmake_minimum_required(VERSION 3.17)
if(RunCMake_TEST STREQUAL "LOCATION")
cmake_minimum_required(VERSION 2.8.12) # Leave CMP0026 unset.
endif()
project(${RunCMake_TEST} NONE) project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE)

View File

@ -1,16 +0,0 @@
^CMake Deprecation Warning at CMakeLists\.txt:3 \(cmake_minimum_required\):
Compatibility with CMake < 3\.10 will be removed from a future version of
CMake\.
Update the VERSION argument <min> value\. Or, use the <min>\.\.\.<max> syntax
to tell CMake that the project requires at least <min> but has been updated
to work with policies introduced by <max> or earlier\.
+
CMake Warning \(dev\) in CMakeLists\.txt:
Policy CMP0026 is not set: Disallow use of the LOCATION target property.
Run "cmake --help-policy CMP0026" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
The LOCATION property should not be read from target "foo". Use the target
name directly with add_custom_command, or use the generator expression
\$<TARGET_FILE>, as appropriate.

View File

@ -1,3 +0,0 @@
enable_language(C)
add_library(foo empty.c)
add_custom_target(drive COMMAND ${CMAKE_COMMAND} -E echo $<TARGET_PROPERTY:foo,LOCATION>)

View File

@ -11,7 +11,6 @@ run_cmake(LinkImplementationCycle3)
run_cmake(LinkImplementationCycle4) run_cmake(LinkImplementationCycle4)
run_cmake(LinkImplementationCycle5) run_cmake(LinkImplementationCycle5)
run_cmake(LinkImplementationCycle6) run_cmake(LinkImplementationCycle6)
run_cmake(LOCATION)
run_cmake(SOURCES) run_cmake(SOURCES)
run_cmake(TransitiveBuild) run_cmake(TransitiveBuild)
run_cmake(TransitiveLink-CMP0166-OLD) run_cmake(TransitiveLink-CMP0166-OLD)

View File

@ -1,10 +0,0 @@
^CMake Deprecation Warning at CMP0026-LOCATION.cmake:[0-9]+ \(cmake_policy\):
The OLD behavior for policy CMP0026 will be removed from a future version
of CMake.
The cmake-policies\(7\) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)$

View File

@ -1,14 +0,0 @@
cmake_policy(SET CMP0026 OLD)
enable_language(CXX)
add_library(objlib OBJECT
empty_1.cpp
)
add_executable(my_exe
empty_2.cpp
$<TARGET_OBJECTS:objlib>
)
get_target_property( loc my_exe LOCATION)

View File

@ -6,7 +6,6 @@ endif()
run_cmake(EmptyKeywordArgs) run_cmake(EmptyKeywordArgs)
run_cmake(OriginDebug) run_cmake(OriginDebug)
run_cmake(CMP0026-LOCATION)
run_cmake(CMP0076-OLD) run_cmake(CMP0076-OLD)
run_cmake(CMP0076-WARN) run_cmake(CMP0076-WARN)
run_cmake(MissingSource) run_cmake(MissingSource)