summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-01-06 16:15:34 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2014-01-06 16:15:34 (GMT)
commitb225dbbd0235b545383105e0571f84a1bf6b1be0 (patch)
treef46e7515eb34bf6c51339a8b0d0cd7958daf09ef /Source
parent1377542db5ab45043d6f3f6546fbd37a12dc9196 (diff)
parenta55c70de78755d7086acaa639a92c9a7480d7938 (diff)
downloadCMake-b225dbbd0235b545383105e0571f84a1bf6b1be0.zip
CMake-b225dbbd0235b545383105e0571f84a1bf6b1be0.tar.gz
CMake-b225dbbd0235b545383105e0571f84a1bf6b1be0.tar.bz2
Merge topic 'minor-cleanups'
a55c70d cmTarget: Remove support for <CONFIG>_LOCATION property. c9f9b3c cmTarget: Test impliedByUse number-compatible properties. fbe1fa7 cmTarget: Don't repeat property origin debug information. 01c545c cmTarget: Fix debug report for interface-set compatibility types. c67e1a6 cmTarget: Fix reporting interface-set properties which are FALSE. 07b0f54 Qt Tests: Remove commented and unneeded line. 79db8ef cmTarget: Fix the property compatibility error message 43340a9 Help: Reformat Qt autogenerator documentation. d98ea6c Help: Mark some code blocks as containing cmake code. ea78935 GenerateExportHeader: Reformat docs. 272a20f cmTarget: Don't update IMPORTED target compilation properties 03d842a Run the add_compile_options command unit test. cd3d0b6 get_property: Fix testing ALIASED_TARGET target property (#14670) 6a62228 install: Ensure that install(TARGETS) works with no DESTINATION af3d3b8 export: Only generate and install configuration files if needed. 0de81bb Help: Workaround pygments reporting an error for genexes. ...
Diffstat (limited to 'Source')
-rw-r--r--Source/cmAddDependenciesCommand.cxx9
-rw-r--r--Source/cmExportInstallFileGenerator.cxx27
-rw-r--r--Source/cmGetPropertyCommand.cxx2
-rw-r--r--Source/cmIncludeDirectoryCommand.cxx2
-rw-r--r--Source/cmMakefile.cxx2
-rw-r--r--Source/cmTarget.cxx197
6 files changed, 133 insertions, 106 deletions
diff --git a/Source/cmAddDependenciesCommand.cxx b/Source/cmAddDependenciesCommand.cxx
index e4d7f7f..87bfb3c 100644
--- a/Source/cmAddDependenciesCommand.cxx
+++ b/Source/cmAddDependenciesCommand.cxx
@@ -33,6 +33,15 @@ bool cmAddDependenciesCommand
}
if(cmTarget* target = this->Makefile->FindTargetToUse(target_name.c_str()))
{
+ if (target->GetType() == cmTarget::INTERFACE_LIBRARY)
+ {
+ cmOStringStream e;
+ e << "Cannot add target-level dependencies to INTERFACE library "
+ "target \"" << target_name << "\".\n";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+
std::vector<std::string>::const_iterator s = args.begin();
++s; // skip over target_name
for (; s != args.end(); ++s)
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index 1025dc0..73e9b31 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -114,13 +114,18 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
std::vector<std::string> missingTargets;
bool require2_8_12 = false;
- bool require2_8_13 = false;
+ bool require3_0_0 = false;
+ bool requiresConfigFiles = false;
// Create all the imported targets.
for(std::vector<cmTargetExport*>::const_iterator
tei = allTargets.begin();
tei != allTargets.end(); ++tei)
{
cmTarget* te = (*tei)->Target;
+
+ requiresConfigFiles = requiresConfigFiles
+ || te->GetType() != cmTarget::INTERFACE_LIBRARY;
+
this->GenerateImportTargetCode(os, te);
ImportPropertyMap properties;
@@ -160,7 +165,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
}
if (te->GetType() == cmTarget::INTERFACE_LIBRARY)
{
- require2_8_13 = true;
+ require3_0_0 = true;
}
this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE",
te, properties);
@@ -169,7 +174,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
this->GenerateInterfaceProperties(te, os, properties);
}
- if (require2_8_13)
+ if (require3_0_0)
{
this->GenerateRequiredCMakeVersion(os, "2.8.12.20131007");
}
@@ -197,15 +202,19 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
}
this->GenerateImportedFileCheckLoop(os);
- // Generate an import file for each configuration.
bool result = true;
- for(std::vector<std::string>::const_iterator
- ci = this->Configurations.begin();
- ci != this->Configurations.end(); ++ci)
+ // Generate an import file for each configuration.
+ // Don't do this if we only export INTERFACE_LIBRARY targets.
+ if (requiresConfigFiles)
{
- if(!this->GenerateImportFileConfig(ci->c_str(), missingTargets))
+ for(std::vector<std::string>::const_iterator
+ ci = this->Configurations.begin();
+ ci != this->Configurations.end(); ++ci)
{
- result = false;
+ if(!this->GenerateImportFileConfig(ci->c_str(), missingTargets))
+ {
+ result = false;
+ }
}
}
diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx
index faba7cd..a1454a3 100644
--- a/Source/cmGetPropertyCommand.cxx
+++ b/Source/cmGetPropertyCommand.cxx
@@ -298,7 +298,7 @@ bool cmGetPropertyCommand::HandleTargetMode()
return this->StoreResult(target->GetName());
}
}
- return false;
+ return this->StoreResult((this->Variable + "-NOTFOUND").c_str());
}
if(cmTarget* target = this->Makefile->FindTargetToUse(this->Name.c_str()))
{
diff --git a/Source/cmIncludeDirectoryCommand.cxx b/Source/cmIncludeDirectoryCommand.cxx
index 30c1743..e20fe02 100644
--- a/Source/cmIncludeDirectoryCommand.cxx
+++ b/Source/cmIncludeDirectoryCommand.cxx
@@ -55,7 +55,7 @@ bool cmIncludeDirectoryCommand
std::vector<std::string> includes;
- GetIncludes(*i, includes);
+ this->GetIncludes(*i, includes);
if (before)
{
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 30a1557..6883f57 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -4045,8 +4045,8 @@ cmMakefile::AddImportedTarget(const char* name, cmTarget::TargetType type,
// Create the target.
cmsys::auto_ptr<cmTarget> target(new cmTarget);
target->SetType(type, name);
- target->SetMakefile(this);
target->MarkAsImported();
+ target->SetMakefile(this);
// Add to the set of available imported targets.
this->ImportedTargets[name] = target.get();
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 9faf0d9..ead48b9 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -136,7 +136,7 @@ public:
std::vector<TargetPropertyEntry*> IncludeDirectoriesEntries;
std::vector<TargetPropertyEntry*> CompileOptionsEntries;
std::vector<TargetPropertyEntry*> CompileDefinitionsEntries;
- std::vector<cmValueWithOrigin> LinkInterfacePropertyEntries;
+ std::vector<cmValueWithOrigin> LinkImplementationPropertyEntries;
mutable std::map<std::string, std::vector<TargetPropertyEntry*> >
CachedLinkInterfaceIncludeDirectoriesEntries;
@@ -330,34 +330,36 @@ void cmTarget::SetMakefile(cmMakefile* mf)
// Save the backtrace of target construction.
this->Makefile->GetBacktrace(this->Internal->Backtrace);
- // Initialize the INCLUDE_DIRECTORIES property based on the current value
- // of the same directory property:
- const std::vector<cmValueWithOrigin> parentIncludes =
- this->Makefile->GetIncludeDirectoriesEntries();
-
- for (std::vector<cmValueWithOrigin>::const_iterator it
- = parentIncludes.begin(); it != parentIncludes.end(); ++it)
+ if (!this->IsImported())
{
- this->InsertInclude(*it);
- }
+ // Initialize the INCLUDE_DIRECTORIES property based on the current value
+ // of the same directory property:
+ const std::vector<cmValueWithOrigin> parentIncludes =
+ this->Makefile->GetIncludeDirectoriesEntries();
- const std::set<cmStdString> parentSystemIncludes =
- this->Makefile->GetSystemIncludeDirectories();
+ for (std::vector<cmValueWithOrigin>::const_iterator it
+ = parentIncludes.begin(); it != parentIncludes.end(); ++it)
+ {
+ this->InsertInclude(*it);
+ }
+ const std::set<cmStdString> parentSystemIncludes =
+ this->Makefile->GetSystemIncludeDirectories();
- for (std::set<cmStdString>::const_iterator it
- = parentSystemIncludes.begin();
- it != parentSystemIncludes.end(); ++it)
- {
- this->SystemIncludeDirectories.insert(*it);
- }
+ for (std::set<cmStdString>::const_iterator it
+ = parentSystemIncludes.begin();
+ it != parentSystemIncludes.end(); ++it)
+ {
+ this->SystemIncludeDirectories.insert(*it);
+ }
- const std::vector<cmValueWithOrigin> parentOptions =
- this->Makefile->GetCompileOptionsEntries();
+ const std::vector<cmValueWithOrigin> parentOptions =
+ this->Makefile->GetCompileOptionsEntries();
- for (std::vector<cmValueWithOrigin>::const_iterator it
- = parentOptions.begin(); it != parentOptions.end(); ++it)
- {
- this->InsertCompileOption(*it);
+ for (std::vector<cmValueWithOrigin>::const_iterator it
+ = parentOptions.begin(); it != parentOptions.end(); ++it)
+ {
+ this->InsertCompileOption(*it);
+ }
}
if (this->GetType() != INTERFACE_LIBRARY)
@@ -1042,8 +1044,8 @@ cmTarget::AddSystemIncludeDirectories(const std::vector<std::string> &incs)
void cmTarget::FinalizeSystemIncludeDirectories()
{
for (std::vector<cmValueWithOrigin>::const_iterator
- it = this->Internal->LinkInterfacePropertyEntries.begin(),
- end = this->Internal->LinkInterfacePropertyEntries.end();
+ it = this->Internal->LinkImplementationPropertyEntries.begin(),
+ end = this->Internal->LinkImplementationPropertyEntries.end();
it != end; ++it)
{
if (!cmGeneratorExpression::IsValidTargetName(it->Value)
@@ -1495,11 +1497,11 @@ void cmTarget::SetProperty(const char* prop, const char* value)
}
if (strcmp(prop, "LINK_LIBRARIES") == 0)
{
- this->Internal->LinkInterfacePropertyEntries.clear();
+ this->Internal->LinkImplementationPropertyEntries.clear();
cmListFileBacktrace lfbt;
this->Makefile->GetBacktrace(lfbt);
cmValueWithOrigin entry(value, lfbt);
- this->Internal->LinkInterfacePropertyEntries.push_back(entry);
+ this->Internal->LinkImplementationPropertyEntries.push_back(entry);
return;
}
this->Properties.SetProperty(prop, value, cmProperty::TARGET);
@@ -1570,7 +1572,7 @@ void cmTarget::AppendProperty(const char* prop, const char* value,
cmListFileBacktrace lfbt;
this->Makefile->GetBacktrace(lfbt);
cmValueWithOrigin entry(value, lfbt);
- this->Internal->LinkInterfacePropertyEntries.push_back(entry);
+ this->Internal->LinkImplementationPropertyEntries.push_back(entry);
return;
}
this->Properties.AppendProperty(prop, value, cmProperty::TARGET, asString);
@@ -1882,8 +1884,8 @@ cmTarget::GetIncludeDirectories(const char *config) const
if (!this->Internal->CacheLinkInterfaceIncludeDirectoriesDone[configString])
{
for (std::vector<cmValueWithOrigin>::const_iterator
- it = this->Internal->LinkInterfacePropertyEntries.begin(),
- end = this->Internal->LinkInterfacePropertyEntries.end();
+ it = this->Internal->LinkImplementationPropertyEntries.begin(),
+ end = this->Internal->LinkImplementationPropertyEntries.end();
it != end; ++it)
{
if (!cmGeneratorExpression::IsValidTargetName(it->Value)
@@ -2111,8 +2113,8 @@ void cmTarget::GetCompileOptions(std::vector<std::string> &result,
if (!this->Internal->CacheLinkInterfaceCompileOptionsDone[configString])
{
for (std::vector<cmValueWithOrigin>::const_iterator
- it = this->Internal->LinkInterfacePropertyEntries.begin(),
- end = this->Internal->LinkInterfacePropertyEntries.end();
+ it = this->Internal->LinkImplementationPropertyEntries.begin(),
+ end = this->Internal->LinkImplementationPropertyEntries.end();
it != end; ++it)
{
if (!cmGeneratorExpression::IsValidTargetName(it->Value)
@@ -2224,8 +2226,8 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list,
if (!this->Internal->CacheLinkInterfaceCompileDefinitionsDone[configString])
{
for (std::vector<cmValueWithOrigin>::const_iterator
- it = this->Internal->LinkInterfacePropertyEntries.begin(),
- end = this->Internal->LinkInterfacePropertyEntries.end();
+ it = this->Internal->LinkImplementationPropertyEntries.begin(),
+ end = this->Internal->LinkImplementationPropertyEntries.end();
it != end; ++it)
{
if (!cmGeneratorExpression::IsValidTargetName(it->Value)
@@ -2720,25 +2722,6 @@ const char *cmTarget::GetProperty(const char* prop,
this->GetLocation(configName.c_str()),
cmProperty::TARGET);
}
- else
- {
- // Support "<CONFIG>_LOCATION" for compatibility.
- int len = static_cast<int>(strlen(prop));
- if(len > 9 && strcmp(prop+len-9, "_LOCATION") == 0)
- {
- std::string configName(prop, len-9);
- if(configName != "IMPORTED")
- {
- if (!this->HandleLocationPropertyPolicy())
- {
- return 0;
- }
- this->Properties.SetProperty(prop,
- this->GetLocation(configName.c_str()),
- cmProperty::TARGET);
- }
- }
- }
}
if(strcmp(prop,"INCLUDE_DIRECTORIES") == 0)
{
@@ -2800,8 +2783,8 @@ const char *cmTarget::GetProperty(const char* prop,
output = "";
std::string sep;
for (std::vector<cmValueWithOrigin>::const_iterator
- it = this->Internal->LinkInterfacePropertyEntries.begin(),
- end = this->Internal->LinkInterfacePropertyEntries.end();
+ it = this->Internal->LinkImplementationPropertyEntries.begin(),
+ end = this->Internal->LinkImplementationPropertyEntries.end();
it != end; ++it)
{
output += sep;
@@ -4257,20 +4240,23 @@ enum CompatibleType
//----------------------------------------------------------------------------
template<typename PropertyType>
-PropertyType consistentProperty(PropertyType lhs, PropertyType rhs,
- CompatibleType t);
+std::pair<bool, PropertyType> consistentProperty(PropertyType lhs,
+ PropertyType rhs,
+ CompatibleType t);
//----------------------------------------------------------------------------
template<>
-bool consistentProperty(bool lhs, bool rhs, CompatibleType)
+std::pair<bool, bool> consistentProperty(bool lhs, bool rhs, CompatibleType)
{
- return lhs == rhs;
+ return std::make_pair(lhs == rhs, lhs);
}
//----------------------------------------------------------------------------
-const char * consistentStringProperty(const char *lhs, const char *rhs)
+std::pair<bool, const char*> consistentStringProperty(const char *lhs,
+ const char *rhs)
{
- return strcmp(lhs, rhs) == 0 ? lhs : 0;
+ const bool b = strcmp(lhs, rhs) == 0;
+ return std::make_pair(b, b ? lhs : 0);
}
#if defined(_MSC_VER) && _MSC_VER <= 1200
@@ -4284,49 +4270,69 @@ cmMinimum(const T& l, const T& r) {return l < r ? l : r;}
#endif
//----------------------------------------------------------------------------
-const char * consistentNumberProperty(const char *lhs, const char *rhs,
- CompatibleType t)
+std::pair<bool, const char*> consistentNumberProperty(const char *lhs,
+ const char *rhs,
+ CompatibleType t)
{
+
+#if defined(_MSC_VER)
+ static const char* const null_ptr = 0;
+#else
+# define null_ptr 0
+#endif
+
double lnum;
double rnum;
if(sscanf(lhs, "%lg", &lnum) != 1 ||
sscanf(rhs, "%lg", &rnum) != 1)
{
- return 0;
+ return std::pair<bool, const char*>(false, null_ptr);
}
+#if !defined(_MSC_VER)
+#undef null_ptr
+#endif
+
if (t == NumberMaxType)
{
- return cmMaximum(lnum, rnum) == lnum ? lhs : rhs;
+ return std::make_pair(true, cmMaximum(lnum, rnum) == lnum ? lhs : rhs);
}
else
{
- return cmMinimum(lnum, rnum) == lnum ? lhs : rhs;
+ return std::make_pair(true, cmMinimum(lnum, rnum) == lnum ? lhs : rhs);
}
}
//----------------------------------------------------------------------------
template<>
-const char* consistentProperty(const char *lhs, const char *rhs,
- CompatibleType t)
+std::pair<bool, const char*> consistentProperty(const char *lhs,
+ const char *rhs,
+ CompatibleType t)
{
if (!lhs && !rhs)
{
- return "";
+ return std::make_pair(true, lhs);
}
if (!lhs)
{
- return rhs ? rhs : "";
+ return std::make_pair(true, rhs);
}
if (!rhs)
{
- return lhs ? lhs : "";
+ return std::make_pair(true, lhs);
}
+
+#if defined(_MSC_VER)
+ static const char* const null_ptr = 0;
+#else
+# define null_ptr 0
+#endif
+
switch(t)
{
case BoolType:
assert(!"consistentProperty for strings called with BoolType");
- return 0;
+ return std::pair<bool, const char*>(false, null_ptr);
case StringType:
return consistentStringProperty(lhs, rhs);
case NumberMinType:
@@ -4334,7 +4340,12 @@ const char* consistentProperty(const char *lhs, const char *rhs,
return consistentNumberProperty(lhs, rhs, t);
}
assert(!"Unreachable!");
- return 0;
+ return std::pair<bool, const char*>(false, null_ptr);
+
+#if !defined(_MSC_VER)
+#undef null_ptr
+#endif
+
}
template<typename PropertyType>
@@ -4506,7 +4517,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
("INTERFACE_" + p).c_str(), 0);
std::string reportEntry;
- if (ifacePropContent)
+ if (ifaceIsSet)
{
reportEntry += " * Target \"";
reportEntry += li->Target->GetName();
@@ -4519,11 +4530,12 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
{
if (ifaceIsSet)
{
- PropertyType consistent = consistentProperty(propContent,
+ std::pair<bool, PropertyType> consistent =
+ consistentProperty(propContent,
ifacePropContent, t);
report += reportEntry;
- report += compatibilityAgree(t, propContent != consistent);
- if (!consistent)
+ report += compatibilityAgree(t, propContent != consistent.second);
+ if (!consistent.first)
{
cmOStringStream e;
e << "Property " << p << " on target \""
@@ -4535,7 +4547,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
}
else
{
- propContent = consistent;
+ propContent = consistent.second;
continue;
}
}
@@ -4549,19 +4561,14 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
{
propContent = impliedValue<PropertyType>(propContent);
- reportEntry += " * Target \"";
- reportEntry += li->Target->GetName();
- reportEntry += "\" property value \"";
- reportEntry += valueAsString<PropertyType>(propContent);
- reportEntry += "\" ";
-
if (ifaceIsSet)
{
- PropertyType consistent = consistentProperty(propContent,
+ std::pair<bool, PropertyType> consistent =
+ consistentProperty(propContent,
ifacePropContent, t);
report += reportEntry;
- report += compatibilityAgree(t, propContent != consistent);
- if (!consistent)
+ report += compatibilityAgree(t, propContent != consistent.second);
+ if (!consistent.first)
{
cmOStringStream e;
e << "Property " << p << " on target \""
@@ -4574,7 +4581,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
}
else
{
- propContent = consistent;
+ propContent = consistent.second;
continue;
}
}
@@ -4590,11 +4597,12 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
{
if (propInitialized)
{
- PropertyType consistent = consistentProperty(propContent,
+ std::pair<bool, PropertyType> consistent =
+ consistentProperty(propContent,
ifacePropContent, t);
report += reportEntry;
- report += compatibilityAgree(t, propContent != consistent);
- if (!consistent)
+ report += compatibilityAgree(t, propContent != consistent.second);
+ if (!consistent.first)
{
cmOStringStream e;
e << "The INTERFACE_" << p << " property of \""
@@ -4606,7 +4614,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
}
else
{
- propContent = consistent;
+ propContent = consistent.second;
continue;
}
}
@@ -6003,7 +6011,8 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info,
<< propsString <<
" property in the dependencies of target \"" << this->GetName() <<
"\". This is not allowed. A property may only require compatibility "
- "in a boolean interpretation or a string interpretation, but not both.";
+ "in a boolean interpretation, a numeric minimum, a numeric maximum or a "
+ "string interpretation, but not a mixture.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
}
}