From 93034a8350102e308fa5bca8d89bf3f6fae12771 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 10 Jan 2013 17:11:12 +0100 Subject: Fix linking to imported libraries test. Make a C executable instead of attempting to make a C++ static library (and not really succeeding). This was introduced in commit 894f52f3 (Handle INTERFACE properties transitively for includes and defines., 2012-09-23). --- Tests/ExportImport/Import/A/CMakeLists.txt | 4 ++-- Tests/ExportImport/Import/A/deps_iface.c | 24 ++++++++++++++++++++++++ Tests/ExportImport/Import/A/deps_iface.cpp | 24 ------------------------ 3 files changed, 26 insertions(+), 26 deletions(-) create mode 100644 Tests/ExportImport/Import/A/deps_iface.c delete mode 100644 Tests/ExportImport/Import/A/deps_iface.cpp diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index b77562e..56cfea0 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -157,8 +157,8 @@ endif() # Test that dependent imported targets have usable # INTERFACE_COMPILE_DEFINITIONS and INTERFACE_INCLUDE_DIRECTORIES -add_library(deps_iface deps_iface.cpp) -target_link_libraries(deps_iface testLibsDepends) +add_executable(deps_iface deps_iface.c) +target_link_libraries(deps_iface testLibDepends) set_property(TARGET deps_iface APPEND PROPERTY COMPILE_DEFINITIONS $ diff --git a/Tests/ExportImport/Import/A/deps_iface.c b/Tests/ExportImport/Import/A/deps_iface.c new file mode 100644 index 0000000..e73ca26 --- /dev/null +++ b/Tests/ExportImport/Import/A/deps_iface.c @@ -0,0 +1,24 @@ + +#include "testLibIncludeRequired1.h" +#include "testLibIncludeRequired2.h" +#include "testLibIncludeRequired6.h" + +#ifndef testLibRequired_IFACE_DEFINE +#error Expected testLibRequired_IFACE_DEFINE +#endif + +#ifdef BuildOnly_DEFINE +#error Unexpected BuildOnly_DEFINE +#endif + +#ifndef InstallOnly_DEFINE +#error Expected InstallOnly_DEFINE +#endif + +extern int testLibDepends(void); + + +int main() +{ + return testLibDepends(); +} diff --git a/Tests/ExportImport/Import/A/deps_iface.cpp b/Tests/ExportImport/Import/A/deps_iface.cpp deleted file mode 100644 index 7190b92..0000000 --- a/Tests/ExportImport/Import/A/deps_iface.cpp +++ /dev/null @@ -1,24 +0,0 @@ - -#include "testLibIncludeRequired1.h" -#include "testLibIncludeRequired2.h" -#include "testLibIncludeRequired6.h" - -#ifndef testLibRequired_IFACE_DEFINE -#error Expected testLibRequired_IFACE_DEFINE -#endif - -#ifdef BuildOnly_DEFINE -#error Unexpected BuildOnly_DEFINE -#endif - -#ifndef InstallOnly_DEFINE -#error Expected InstallOnly_DEFINE -#endif - -extern int testLibDepends(void); - - -int main(int,char **) -{ - return testLibDepends(); -} -- cgit v0.12 From f99196dc0cde6e5868cc74c603a78b10f1ba324a Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 10 Dec 2012 12:00:34 +0100 Subject: Add cmGeneratorExpression::Split() API. It can split a string like "A;$<1:B>;$<1:C>;D;E;$<1:F;G;H>;$<1:I>;J" into "A" "$<1:B>" "$<1:C>" "D" "E" "$<1:F;G;H>" "$<1:I>" "J" --- Source/cmGeneratorExpression.cxx | 61 ++++++++++++++++++++++++++++++++++++++++ Source/cmGeneratorExpression.h | 3 ++ 2 files changed, 64 insertions(+) diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 4063697..d306dee 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -251,6 +251,67 @@ static std::string stripExportInterface(const std::string &input, } //---------------------------------------------------------------------------- +void cmGeneratorExpression::Split(const std::string &input, + std::vector &output) +{ + std::string::size_type pos = 0; + std::string::size_type lastPos = pos; + while((pos = input.find("$<", lastPos)) != input.npos) + { + std::string part = input.substr(lastPos, pos - lastPos); + std::string preGenex; + if (!part.empty()) + { + std::string::size_type startPos = input.rfind(";", pos); + if (startPos != pos - 1 && startPos >= lastPos) + { + part = input.substr(lastPos, startPos - lastPos); + preGenex = input.substr(startPos + 1, pos - startPos - 1); + } + cmSystemTools::ExpandListArgument(part.c_str(), output); + } + pos += 2; + int nestingLevel = 1; + const char *c = input.c_str() + pos; + const char * const cStart = c; + for ( ; *c; ++c) + { + if(c[0] == '$' && c[1] == '<') + { + ++nestingLevel; + ++c; + continue; + } + if(c[0] == '>') + { + --nestingLevel; + if (nestingLevel == 0) + { + break; + } + } + } + for ( ; *c; ++c) + { + // Capture the part after the genex and before the next ';' + if(c[0] == ';') + { + --c; + break; + } + } + const std::string::size_type traversed = (c - cStart) + 1; + output.push_back(preGenex + "$<" + input.substr(pos, traversed)); + pos += traversed; + lastPos = pos; + } + if (lastPos < input.size()) + { + cmSystemTools::ExpandListArgument(input.substr(lastPos), output); + } +} + +//---------------------------------------------------------------------------- std::string cmGeneratorExpression::Preprocess(const std::string &input, PreprocessContext context) { diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h index b58dde5..8f1aef6 100644 --- a/Source/cmGeneratorExpression.h +++ b/Source/cmGeneratorExpression.h @@ -59,6 +59,9 @@ public: static std::string Preprocess(const std::string &input, PreprocessContext context); + static void Split(const std::string &input, + std::vector &output); + private: cmGeneratorExpression(const cmGeneratorExpression &); void operator=(const cmGeneratorExpression &); -- cgit v0.12 From cb1afbf466d126f233e93b2cdfa3f5c5dfe5b8f7 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 8 Jan 2013 21:06:24 +0100 Subject: Don't pass a position when determining if a target name is a literal. The lastPos refers to a position in a different string. --- Source/cmExportFileGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 90c0c41..56b088e 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -270,7 +270,7 @@ cmExportFileGenerator::ResolveTargetsInGeneratorExpressions( } const std::string targetName = input.substr(nameStartPos, endPos - nameStartPos); - if(targetName.find("$<", lastPos) != input.npos) + if(targetName.find("$<") != input.npos) { errorString = "$ requires its parameter to be a " "literal."; -- cgit v0.12 From b6036d104a95156e8524dbfeb5533d3a579d8837 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 8 Jan 2013 20:58:33 +0100 Subject: Extract the AddTargetNamespace method. --- Source/cmExportFileGenerator.cxx | 143 +++++++++++++-------------------------- Source/cmExportFileGenerator.h | 4 ++ 2 files changed, 52 insertions(+), 95 deletions(-) diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 56b088e..da18856 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -184,6 +184,41 @@ void cmExportFileGenerator::GenerateInterfaceProperties(cmTarget *target, } //---------------------------------------------------------------------------- +bool +cmExportFileGenerator::AddTargetNamespace(std::string &input, + cmTarget* target, + std::vector &missingTargets) +{ + cmMakefile *mf = target->GetMakefile(); + + cmTarget *tgt = mf->FindTargetToUse(input.c_str()); + if (!tgt) + { + return false; + } + + if(tgt->IsImported()) + { + return true; + } + if(this->ExportedTargets.find(tgt) != this->ExportedTargets.end()) + { + input = this->Namespace + input; + } + else + { + std::string namespacedTarget; + this->HandleMissingTarget(namespacedTarget, missingTargets, + mf, target, tgt); + if (!namespacedTarget.empty()) + { + input = namespacedTarget; + } + } + return true; +} + +//---------------------------------------------------------------------------- void cmExportFileGenerator::ResolveTargetsInGeneratorExpressions( std::string &input, @@ -212,45 +247,17 @@ cmExportFileGenerator::ResolveTargetsInGeneratorExpressions( continue; } - const std::string targetName = input.substr(nameStartPos, + std::string targetName = input.substr(nameStartPos, commaPos - nameStartPos); - pos = nameStartPos; // We're not going to replace the entire expression, - // but only the target parameter. - if (cmTarget *tgt = mf->FindTargetToUse(targetName.c_str())) - { - if(tgt->IsImported()) - { - pos += targetName.size(); - } - else if(this->ExportedTargets.find(tgt) != this->ExportedTargets.end()) - { - input.replace(pos, targetName.size(), - this->Namespace + targetName); - pos += this->Namespace.size() + targetName.size(); - } - else - { - std::string namespacedTarget; - this->HandleMissingTarget(namespacedTarget, missingTargets, - mf, target, tgt); - if (!namespacedTarget.empty()) - { - input.replace(pos, targetName.size(), namespacedTarget); - pos += namespacedTarget.size(); - } - } - } - else + if (!this->AddTargetNamespace(targetName, target, missingTargets)) { errorString = "$ requires " "its first parameter to be a reachable target."; - } - lastPos = pos; - if (!errorString.empty()) - { break; } + input.replace(nameStartPos, commaPos - nameStartPos, targetName); + lastPos = pos + targetName.size(); } if (!errorString.empty()) { @@ -267,51 +274,24 @@ cmExportFileGenerator::ResolveTargetsInGeneratorExpressions( if (endPos == input.npos) { errorString = "$ expression incomplete"; + break; } - const std::string targetName = input.substr(nameStartPos, + std::string targetName = input.substr(nameStartPos, endPos - nameStartPos); if(targetName.find("$<") != input.npos) { errorString = "$ requires its parameter to be a " "literal."; + break; } - if (cmTarget *tgt = mf->FindTargetToUse(targetName.c_str())) - { - if(tgt->IsImported()) - { - input.replace(pos, sizeof("$ExportedTargets.find(tgt) != this->ExportedTargets.end()) - { - input.replace(pos, sizeof("$Namespace + targetName); - pos += sizeof("$HandleMissingTarget(namespacedTarget, missingTargets, - mf, target, tgt); - if (!namespacedTarget.empty()) - { - input.replace(pos, sizeof("$AddTargetNamespace(targetName, target, missingTargets)) { errorString = "$ requires its parameter to be a " "reachable target."; - } - lastPos = pos; - if (!errorString.empty()) - { break; } + input.replace(pos, endPos - pos + 1, targetName); + lastPos = endPos; } if (!errorString.empty()) { @@ -397,9 +377,6 @@ cmExportFileGenerator return; } - // Get the makefile in which to lookup target information. - cmMakefile* mf = target->GetMakefile(); - // Construct the property value. std::string link_libs; const char* sep = ""; @@ -410,33 +387,9 @@ cmExportFileGenerator link_libs += sep; sep = ";"; - // Append this entry. - if(cmTarget* tgt = mf->FindTargetToUse(li->c_str())) - { - // This is a target. - if(tgt->IsImported()) - { - // The target is imported (and therefore is not in the - // export). Append the raw name. - link_libs += *li; - } - else if(this->ExportedTargets.find(tgt) != this->ExportedTargets.end()) - { - // The target is in the export. Append it with the export - // namespace. - link_libs += this->Namespace; - link_libs += *li; - } - else - { - this->HandleMissingTarget(link_libs, missingTargets, mf, target, tgt); - } - } - else - { - // Append the raw name. - link_libs += *li; - } + std::string temp = *li; + this->AddTargetNamespace(temp, target, missingTargets); + link_libs += temp; } // Store the property. diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 7c58ad8..a5b25f4 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -128,6 +128,10 @@ private: cmGeneratorExpression::PreprocessContext, ImportPropertyMap &properties, std::vector &missingTargets); + + bool AddTargetNamespace(std::string &input, cmTarget* target, + std::vector &missingTargets); + }; #endif -- cgit v0.12 From a3aedb8152ad6fcdb42fd04e45307eea6ce0043e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 4 Jan 2013 15:56:13 +0100 Subject: Split the generator expression before extracting targets. Now that we're processing a LINK_INTERFACE_LIBRARIES string, it can contain targets. Make sure they are extracted for namespacing purposes. This needs to be restricted to strings which can actually have targets named in them. For example, this is not done for INTERFACE_COMPILE_DEFINITIONS, because even if there is a target named 'foo', the string 'foo' in that property means that '-Dfoo' will be set when compiling. --- Source/cmExportFileGenerator.cxx | 45 ++++++++++++++++++++++++++++++++++++++++ Source/cmExportFileGenerator.h | 14 +++++++++++-- 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index da18856..df8f3e8 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -219,10 +219,55 @@ cmExportFileGenerator::AddTargetNamespace(std::string &input, } //---------------------------------------------------------------------------- +static bool isGeneratorExpression(const std::string &lib) +{ + const std::string::size_type openpos = lib.find("$<"); + return (openpos != std::string::npos) + && (lib.find(">", openpos) != std::string::npos); +} + +//---------------------------------------------------------------------------- void cmExportFileGenerator::ResolveTargetsInGeneratorExpressions( std::string &input, cmTarget* target, + std::vector &missingTargets, + FreeTargetsReplace replace) +{ + if (replace == NoReplaceFreeTargets) + { + this->ResolveTargetsInGeneratorExpression(input, target, missingTargets); + return; + } + std::vector parts; + cmGeneratorExpression::Split(input, parts); + + std::string sep; + input = ""; + for(std::vector::iterator li = parts.begin(); + li != parts.end(); ++li) + { + if (!isGeneratorExpression(*li)) + { + this->AddTargetNamespace(*li, target, missingTargets); + } + else + { + this->ResolveTargetsInGeneratorExpression( + *li, + target, + missingTargets); + } + input += sep + *li; + sep = ";"; + } +} + +//---------------------------------------------------------------------------- +void +cmExportFileGenerator::ResolveTargetsInGeneratorExpression( + std::string &input, + cmTarget* target, std::vector &missingTargets) { std::string::size_type pos = 0; diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index a5b25f4..866806b 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -102,9 +102,16 @@ protected: void GenerateInterfaceProperties(cmTarget *target, std::ostream& os, const ImportPropertyMap &properties); + + enum FreeTargetsReplace { + ReplaceFreeTargets, + NoReplaceFreeTargets + }; + void ResolveTargetsInGeneratorExpressions(std::string &input, - cmTarget* target, - std::vector &missingTargets); + cmTarget* target, + std::vector &missingTargets, + FreeTargetsReplace replace = NoReplaceFreeTargets); // The namespace in which the exports are placed in the generated file. std::string Namespace; @@ -132,6 +139,9 @@ private: bool AddTargetNamespace(std::string &input, cmTarget* target, std::vector &missingTargets); + void ResolveTargetsInGeneratorExpression(std::string &input, + cmTarget* target, + std::vector &missingTargets); }; #endif -- cgit v0.12 From 94aeaf72c714eb184ec61bf6e7bc573bd1bc15c9 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 4 Jan 2013 15:58:16 +0100 Subject: Split LINK_INTERFACE_LIBRARIES export handling into dedicated method. --- Source/cmExportBuildFileGenerator.cxx | 4 ++++ Source/cmExportFileGenerator.cxx | 24 +++++++++++++++++++++--- Source/cmExportFileGenerator.h | 4 ++++ Source/cmExportInstallFileGenerator.cxx | 4 ++++ 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 9533319..29f6743 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -107,6 +107,10 @@ cmExportBuildFileGenerator std::vector missingTargets; this->SetImportDetailProperties(config, suffix, target, properties, missingTargets); + this->SetImportLinkInterface(config, suffix, + cmGeneratorExpression::BuildInterface, + target, properties, missingTargets); + // TOOD: PUBLIC_HEADER_LOCATION // This should wait until the build feature propagation stuff diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index df8f3e8..5e5f455 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -347,6 +347,26 @@ cmExportFileGenerator::ResolveTargetsInGeneratorExpression( //---------------------------------------------------------------------------- void cmExportFileGenerator +::SetImportLinkInterface(const char* config, std::string const& suffix, + cmGeneratorExpression::PreprocessContext preprocessRule, + cmTarget* target, ImportPropertyMap& properties, + std::vector& missingTargets) +{ + // Add the transitive link dependencies for this configuration. + cmTarget::LinkInterface const* iface = target->GetLinkInterface(config, + target); + if (!iface) + { + return; + } + this->SetImportLinkProperty(suffix, target, + "IMPORTED_LINK_INTERFACE_LIBRARIES", + iface->Libraries, properties, missingTargets); +} + +//---------------------------------------------------------------------------- +void +cmExportFileGenerator ::SetImportDetailProperties(const char* config, std::string const& suffix, cmTarget* target, ImportPropertyMap& properties, std::vector& missingTargets @@ -388,9 +408,7 @@ cmExportFileGenerator this->SetImportLinkProperty(suffix, target, "IMPORTED_LINK_INTERFACE_LANGUAGES", iface->Languages, properties, missingTargets); - this->SetImportLinkProperty(suffix, target, - "IMPORTED_LINK_INTERFACE_LIBRARIES", - iface->Libraries, properties, missingTargets); + this->SetImportLinkProperty(suffix, target, "IMPORTED_LINK_DEPENDENT_LIBRARIES", iface->SharedDeps, properties, missingTargets); diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 866806b..4d97a63 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -102,6 +102,10 @@ protected: void GenerateInterfaceProperties(cmTarget *target, std::ostream& os, const ImportPropertyMap &properties); + void SetImportLinkInterface(const char* config, std::string const& suffix, + cmGeneratorExpression::PreprocessContext preprocessRule, + cmTarget* target, ImportPropertyMap& properties, + std::vector& missingTargets); enum FreeTargetsReplace { ReplaceFreeTargets, diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index bc953c9..68881a1 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -229,6 +229,10 @@ cmExportInstallFileGenerator this->SetImportDetailProperties(config, suffix, te->Target, properties, missingTargets); + this->SetImportLinkInterface(config, suffix, + cmGeneratorExpression::InstallInterface, + te->Target, properties, missingTargets); + // TOOD: PUBLIC_HEADER_LOCATION // This should wait until the build feature propagation stuff // is done. Then this can be a propagated include directory. -- cgit v0.12 From 77d26467848fd689fbbffbaa302d041aa2365b15 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 4 Jan 2013 13:36:18 +0100 Subject: Allow generator expressions in LINK_INTERFACE_LIBRARIES. The Config and IMPORTED_ variants may also contain generator expressions. If 'the implementation is the interface', then the result of evaluating the expressions at generate time is used to populate the IMPORTED_LINK_INTERFACE_LIBRARIES property. 1) In the case of non-static libraries, this is fine because the user still has the option to populate the LINK_INTERFACE_LIBRARIES with generator expressions if that is what is wanted. 2) In the case of static libraries, this prevents a footgun, enforcing that the interface and the implementation are really the same. Otherwise, the LINK_LIBRARIES could contain a generator expression which is evaluated with a different context at build time, and when used as an imported target. That would mean that the result of evaluating the INTERFACE_LINK_LIBRARIES property for a static library would not necessarily be the 'link implementation'. For example: add_library(libone STATIC libone.cpp) add_library(libtwo STATIC libtwo.cpp) add_library(libthree STATIC libthree.cpp) target_link_libraries(libtwo $<$,STATIC_LIBRARY>:libone>) target_link_libraries(libthree libtwo) If the LINK_LIBRARIES content was simply copied to the IMPORTED_LINK_INTERFACE_LIBRARIES, then libthree links to libone, but executables linking to libthree will not link to libone. 3) As the 'implementation is the interface' concept is to be deprecated in the future anyway, this should be fine. --- Source/cmExportFileGenerator.cxx | 44 +++++++++++++++++-- Source/cmTarget.cxx | 50 ++++++++++++++++------ Source/cmTarget.h | 4 +- .../target_link_libraries/CMakeLists.txt | 10 +++++ Tests/CMakeCommands/target_link_libraries/depD.cpp | 13 ++++++ Tests/CMakeCommands/target_link_libraries/depD.h | 11 +++++ .../target_link_libraries/targetB.cpp | 10 +++++ Tests/ExportImport/Export/CMakeLists.txt | 33 +++++++++++++- Tests/ExportImport/Export/testSharedLibDepends.cpp | 8 ++++ Tests/ExportImport/Export/testSharedLibDepends.h | 14 ++++++ .../ExportImport/Export/testSharedLibRequired.cpp | 7 +++ Tests/ExportImport/Export/testSharedLibRequired.h | 12 ++++++ Tests/ExportImport/Import/A/CMakeLists.txt | 11 +++++ Tests/ExportImport/Import/A/deps_shared_iface.cpp | 11 +++++ 14 files changed, 221 insertions(+), 17 deletions(-) create mode 100644 Tests/CMakeCommands/target_link_libraries/depD.cpp create mode 100644 Tests/CMakeCommands/target_link_libraries/depD.h create mode 100644 Tests/CMakeCommands/target_link_libraries/targetB.cpp create mode 100644 Tests/ExportImport/Export/testSharedLibDepends.cpp create mode 100644 Tests/ExportImport/Export/testSharedLibDepends.h create mode 100644 Tests/ExportImport/Export/testSharedLibRequired.cpp create mode 100644 Tests/ExportImport/Export/testSharedLibRequired.h create mode 100644 Tests/ExportImport/Import/A/deps_shared_iface.cpp diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 5e5f455..94e24c7 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -359,9 +359,47 @@ cmExportFileGenerator { return; } - this->SetImportLinkProperty(suffix, target, - "IMPORTED_LINK_INTERFACE_LIBRARIES", - iface->Libraries, properties, missingTargets); + + if (iface->ImplementationIsInterface) + { + this->SetImportLinkProperty(suffix, target, + "IMPORTED_LINK_INTERFACE_LIBRARIES", + iface->Libraries, properties, missingTargets); + return; + } + + const char *propContent; + + if (const char *prop_suffixed = target->GetProperty( + ("LINK_INTERFACE_LIBRARIES" + suffix).c_str())) + { + propContent = prop_suffixed; + } + else if (const char *prop = target->GetProperty( + "LINK_INTERFACE_LIBRARIES")) + { + propContent = prop; + } + else + { + return; + } + + if (!*propContent) + { + properties["IMPORTED_LINK_INTERFACE_LIBRARIES" + suffix] = ""; + return; + } + + std::string prepro = cmGeneratorExpression::Preprocess(propContent, + preprocessRule); + if (!prepro.empty()) + { + this->ResolveTargetsInGeneratorExpressions(prepro, target, + missingTargets, + ReplaceFreeTargets); + properties["IMPORTED_LINK_INTERFACE_LIBRARIES" + suffix] = prepro; + } } //---------------------------------------------------------------------------- diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 2cfb1bf..9b50b8e 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4896,16 +4896,30 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, { std::string linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES"; linkProp += suffix; - if(const char* config_libs = this->GetProperty(linkProp.c_str())) + + const char *propertyLibs = this->GetProperty(linkProp.c_str()); + + if(!propertyLibs) { - cmSystemTools::ExpandListArgument(config_libs, - info.LinkInterface.Libraries); + linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES"; + propertyLibs = this->GetProperty(linkProp.c_str()); } - else if(const char* libs = - this->GetProperty("IMPORTED_LINK_INTERFACE_LIBRARIES")) + if(propertyLibs) { - cmSystemTools::ExpandListArgument(libs, - info.LinkInterface.Libraries); + cmListFileBacktrace lfbt; + cmGeneratorExpression ge(lfbt); + + cmGeneratorExpressionDAGChecker dagChecker(lfbt, + this->GetName(), + linkProp, 0, 0); + cmSystemTools::ExpandListArgument(ge.Parse(propertyLibs) + ->Evaluate(this->Makefile, + desired_config.c_str(), + false, + headTarget, + this, + &dagChecker), + info.LinkInterface.Libraries); } } @@ -5019,18 +5033,20 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, // An explicit list of interface libraries may be set for shared // libraries and executables that export symbols. const char* explicitLibraries = 0; + std::string linkIfaceProp; if(this->GetType() == cmTarget::SHARED_LIBRARY || this->IsExecutableWithExports()) { // Lookup the per-configuration property. - std::string propName = "LINK_INTERFACE_LIBRARIES"; - propName += suffix; - explicitLibraries = this->GetProperty(propName.c_str()); + linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; + linkIfaceProp += suffix; + explicitLibraries = this->GetProperty(linkIfaceProp.c_str()); // If not set, try the generic property. if(!explicitLibraries) { - explicitLibraries = this->GetProperty("LINK_INTERFACE_LIBRARIES"); + linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; + explicitLibraries = this->GetProperty(linkIfaceProp.c_str()); } } @@ -5048,7 +5064,16 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, if(explicitLibraries) { // The interface libraries have been explicitly set. - cmSystemTools::ExpandListArgument(explicitLibraries, iface.Libraries); + cmListFileBacktrace lfbt; + cmGeneratorExpression ge(lfbt); + cmGeneratorExpressionDAGChecker dagChecker(lfbt, this->GetName(), + linkIfaceProp, 0, 0); + cmSystemTools::ExpandListArgument(ge.Parse(explicitLibraries)->Evaluate( + this->Makefile, + config, + false, + headTarget, + this, &dagChecker), iface.Libraries); if(this->GetType() == cmTarget::SHARED_LIBRARY) { @@ -5091,6 +5116,7 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, // The link implementation is the default link interface. LinkImplementation const* impl = this->GetLinkImplementation(config, headTarget); + iface.ImplementationIsInterface = true; iface.Libraries = impl->Libraries; iface.WrongConfigLibraries = impl->WrongConfigLibraries; if(this->GetType() == cmTarget::STATIC_LIBRARY) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 1188a6a..b4d053d 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -258,7 +258,9 @@ public: // Needed only for OLD behavior of CMP0003. std::vector WrongConfigLibraries; - LinkInterface(): Multiplicity(0) {} + bool ImplementationIsInterface; + + LinkInterface(): Multiplicity(0), ImplementationIsInterface(false) {} }; /** Get the link interface for the given configuration. Returns 0 diff --git a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt index 746d30c..1551c50 100644 --- a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt +++ b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt @@ -80,3 +80,13 @@ assert_property(targetA LINK_INTERFACE_LIBRARIES "") add_library(depIfaceOnly SHARED EXCLUDE_FROM_ALL depIfaceOnly.cpp) generate_export_header(depIfaceOnly) set_property(TARGET depB APPEND PROPERTY LINK_INTERFACE_LIBRARIES depIfaceOnly) + +add_library(depD SHARED depD.cpp) +generate_export_header(depD) +set_property(TARGET depD APPEND PROPERTY + LINK_INTERFACE_LIBRARIES + $<$,EXECUTABLE>:depA> +) + +add_executable(targetB targetB.cpp) +target_link_libraries(targetB depD) diff --git a/Tests/CMakeCommands/target_link_libraries/depD.cpp b/Tests/CMakeCommands/target_link_libraries/depD.cpp new file mode 100644 index 0000000..b02c76c --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/depD.cpp @@ -0,0 +1,13 @@ + +#include "depD.h" + +int DepD::foo() +{ + return 0; +} + +DepA DepD::getA() +{ + DepA a; + return a; +} diff --git a/Tests/CMakeCommands/target_link_libraries/depD.h b/Tests/CMakeCommands/target_link_libraries/depD.h new file mode 100644 index 0000000..d24ff5f --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/depD.h @@ -0,0 +1,11 @@ + +#include "depd_export.h" + +#include "depA.h" + +struct DEPD_EXPORT DepD +{ + int foo(); + + DepA getA(); +}; diff --git a/Tests/CMakeCommands/target_link_libraries/targetB.cpp b/Tests/CMakeCommands/target_link_libraries/targetB.cpp new file mode 100644 index 0000000..063d63a --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/targetB.cpp @@ -0,0 +1,10 @@ + +#include "depD.h" + +int main(int argc, char **argv) +{ + DepD d; + DepA a = d.getA(); + + return d.foo() + a.foo(); +} diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index 569845a..779d889 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -158,6 +158,36 @@ set_property(TARGET testLibRequired APPEND PROPERTY $ ) +include(GenerateExportHeader) + +add_library(testSharedLibRequired SHARED testSharedLibRequired.cpp) +generate_export_header(testSharedLibRequired) +set_property(TARGET testSharedLibRequired APPEND PROPERTY + INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}" +) +set_property(TARGET testSharedLibRequired APPEND PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}" +) + +add_library(testSharedLibDepends SHARED testSharedLibDepends.cpp) +set_property(TARGET testSharedLibDepends APPEND PROPERTY + INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}" +) +generate_export_header(testSharedLibDepends) + +set_property(TARGET testSharedLibDepends APPEND PROPERTY + INTERFACE_INCLUDE_DIRECTORIES + $ +) +set_property(TARGET testSharedLibDepends APPEND PROPERTY + LINK_INTERFACE_LIBRARIES + $<1:$> +) + +# LINK_PRIVATE because the LINK_INTERFACE_LIBRARIES is specified above. +target_link_libraries(testSharedLibDepends LINK_PRIVATE testSharedLibRequired) + install(TARGETS testLibRequired testLibIncludeRequired1 testLibIncludeRequired2 @@ -165,10 +195,11 @@ install(TARGETS testLibRequired testLibIncludeRequired4 testLibIncludeRequired5 testLibIncludeRequired6 + testSharedLibRequired EXPORT RequiredExp DESTINATION lib ) install(EXPORT RequiredExp NAMESPACE Req:: FILE testLibRequiredConfig.cmake DESTINATION lib/cmake/testLibRequired) -install(TARGETS testLibDepends EXPORT DependsExp DESTINATION lib ) +install(TARGETS testLibDepends testSharedLibDepends EXPORT DependsExp DESTINATION lib ) install(EXPORT DependsExp FILE testLibDependsConfig.cmake DESTINATION lib/cmake/testLibDepends) diff --git a/Tests/ExportImport/Export/testSharedLibDepends.cpp b/Tests/ExportImport/Export/testSharedLibDepends.cpp new file mode 100644 index 0000000..e279207 --- /dev/null +++ b/Tests/ExportImport/Export/testSharedLibDepends.cpp @@ -0,0 +1,8 @@ + +#include "testSharedLibDepends.h" + +int TestSharedLibDepends::foo() +{ + TestSharedLibRequired req; + return req.foo(); +} diff --git a/Tests/ExportImport/Export/testSharedLibDepends.h b/Tests/ExportImport/Export/testSharedLibDepends.h new file mode 100644 index 0000000..b93143a --- /dev/null +++ b/Tests/ExportImport/Export/testSharedLibDepends.h @@ -0,0 +1,14 @@ + +#ifndef TESTSHAREDLIBDEPENDS_H +#define TESTSHAREDLIBDEPENDS_H + +#include "testsharedlibdepends_export.h" + +#include "testSharedLibRequired.h" + +struct TESTSHAREDLIBDEPENDS_EXPORT TestSharedLibDepends +{ + int foo(); +}; + +#endif diff --git a/Tests/ExportImport/Export/testSharedLibRequired.cpp b/Tests/ExportImport/Export/testSharedLibRequired.cpp new file mode 100644 index 0000000..1ac34aa --- /dev/null +++ b/Tests/ExportImport/Export/testSharedLibRequired.cpp @@ -0,0 +1,7 @@ + +#include "testSharedLibRequired.h" + +int TestSharedLibRequired::foo() +{ + return 0; +} diff --git a/Tests/ExportImport/Export/testSharedLibRequired.h b/Tests/ExportImport/Export/testSharedLibRequired.h new file mode 100644 index 0000000..edaddd4 --- /dev/null +++ b/Tests/ExportImport/Export/testSharedLibRequired.h @@ -0,0 +1,12 @@ + +#ifndef TESTSHAREDLIBREQUIRED_H +#define TESTSHAREDLIBREQUIRED_H + +#include "testsharedlibrequired_export.h" + +struct TESTSHAREDLIBREQUIRED_EXPORT TestSharedLibRequired +{ + int foo(); +}; + +#endif diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index 56cfea0..abb2ab0 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -167,3 +167,14 @@ set_property(TARGET deps_iface APPEND PROPERTY INCLUDE_DIRECTORIES $ ) + +add_executable(deps_shared_iface deps_shared_iface.cpp) +target_link_libraries(deps_shared_iface testSharedLibDepends) +set_property(TARGET deps_shared_iface APPEND PROPERTY + COMPILE_DEFINITIONS + $ +) +set_property(TARGET deps_shared_iface APPEND PROPERTY + INCLUDE_DIRECTORIES + $ +) diff --git a/Tests/ExportImport/Import/A/deps_shared_iface.cpp b/Tests/ExportImport/Import/A/deps_shared_iface.cpp new file mode 100644 index 0000000..4f7eb23 --- /dev/null +++ b/Tests/ExportImport/Import/A/deps_shared_iface.cpp @@ -0,0 +1,11 @@ + + +#include "testSharedLibDepends.h" + +int main(int,char **) +{ + TestSharedLibDepends dep; + TestSharedLibRequired req; + + return dep.foo() + req.foo(); +} -- cgit v0.12 From 5929086634e362d03d02124eea5ee14919ae5a0f Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Fri, 11 Jan 2013 00:01:18 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index f77d17c..c71ba21 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130110) +set(CMake_VERSION_TWEAK 20130111) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 8ff1d4714fb7cd42eb3cd8db041b529e433eb7c8 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 11 Jan 2013 10:57:39 -0500 Subject: CMake: Skip empty link.txt lines (#13845) In the implementation of "cmake -E cmake_link_script", skip lines from the input file that are empty or contain only whitespace. Do not try to run a child with no command line. --- Source/cmake.cxx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index a44c825..0acd2fc 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -3299,6 +3299,12 @@ int cmake::ExecuteLinkScript(std::vector& args) int result = 0; while(result == 0 && cmSystemTools::GetLineFromStream(fin, command)) { + // Skip empty command lines. + if(command.find_first_not_of(" \t") == command.npos) + { + continue; + } + // Setup this command line. const char* cmd[2] = {command.c_str(), 0}; cmsysProcess_SetCommand(cp, cmd); -- cgit v0.12 From 6318834b95fb4e666f9c135a883bb953579c3c8a Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Thu, 10 Jan 2013 18:34:34 +0100 Subject: KWSys 2013-01-10 (608d6b47) Extract upstream KWSys using the following shell commands. $ git archive --prefix=upstream-kwsys/ 608d6b47 | tar x $ git shortlog --no-merges --abbrev=8 --format='%h %s' fc60c8b8..608d6b47 Rolf Eike Beer (6): 297758a5 SystemInformation: fix conversion warning 79ef34ef SystemInformation: fix calling kwsysProcess_WaitForData() f1068caf SystemInformation: speed up copying process data 7dfc27d5 SystemInformation: check CPU vendor and SSE support on OpenBSD 494d9d7a SystemInformation: get stepping code on Intel Macs 608d6b47 SystemInformation: determine processor features on Intel Macs Change-Id: I7f5bc5b7af2bf7d4e5c1ee291c286add0f17a7d5 --- CMakeLists.txt | 7 +++ SystemInformation.cxx | 129 +++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 130 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6bfcab0..5df5a74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -603,6 +603,13 @@ IF(KWSYS_USE_SystemInformation) COMPILE_DEFINITIONS KWSYS_SYS_HAS_MPCTL_H=1) ENDIF() ENDIF() + IF(CMAKE_SYSTEM MATCHES "BSD") + CHECK_INCLUDE_FILES("machine/cpu.h" KWSYS_SYS_HAS_MACHINE_CPU_H) + IF(KWSYS_SYS_HAS_MACHINE_CPU_H) + SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY + COMPILE_DEFINITIONS KWSYS_SYS_HAS_MACHINE_CPU_H=1) + ENDIF() + ENDIF() IF(KWSYS_LFS_AVAILABLE AND NOT KWSYS_LFS_DISABLE) SET(KWSYS_PLATFORM_CXX_TEST_DEFINES -DKWSYS_HAS_LFS=1) ENDIF() diff --git a/SystemInformation.cxx b/SystemInformation.cxx index 0460b29..59a9abe 100644 --- a/SystemInformation.cxx +++ b/SystemInformation.cxx @@ -91,6 +91,10 @@ typedef int siginfo_t; # include #endif +#if defined(KWSYS_SYS_HAS_MACHINE_CPU_H) +# include +#endif + #if defined(__DragonFly__) # include #endif @@ -3026,7 +3030,7 @@ bool SystemInformationImplementation::QueryProcessor() return false; } - this->NumberOfPhysicalCPU = c; + this->NumberOfPhysicalCPU = static_cast(c); this->NumberOfLogicalCPU = this->NumberOfPhysicalCPU; return true; @@ -4000,6 +4004,81 @@ bool SystemInformationImplementation::ParseSysCtl() len = sizeof(value); err = sysctlbyname("machdep.cpu.model", &value, &len, NULL, 0); this->ChipID.Model = static_cast< int >( value ); + + // Chip Stepping + len = sizeof(value); + value = 0; + err = sysctlbyname("machdep.cpu.stepping", &value, &len, NULL, 0); + if (!err) + { + this->ChipID.Revision = static_cast< int >( value ); + } + + // feature string + char *buf = 0; + size_t allocSize = 128; + + err = 0; + len = 0; + + // sysctlbyname() will return with err==0 && len==0 if the buffer is too small + while (err == 0 && len == 0) + { + delete[] buf; + allocSize *= 2; + buf = new char[allocSize]; + if (!buf) + { + break; + } + buf[0] = ' '; + len = allocSize - 2; // keep space for leading and trailing space + err = sysctlbyname("machdep.cpu.features", buf + 1, &len, NULL, 0); + } + if (!err && buf && len) + { + // now we can match every flags as space + flag + space + buf[len + 1] = ' '; + kwsys_stl::string cpuflags(buf, len + 2); + + if ((cpuflags.find(" FPU ")!=kwsys_stl::string::npos)) + { + this->Features.HasFPU = true; + } + if ((cpuflags.find(" TSC ")!=kwsys_stl::string::npos)) + { + this->Features.HasTSC = true; + } + if ((cpuflags.find(" MMX ")!=kwsys_stl::string::npos)) + { + this->Features.HasMMX = true; + } + if ((cpuflags.find(" SSE ")!=kwsys_stl::string::npos)) + { + this->Features.HasSSE = true; + } + if ((cpuflags.find(" SSE2 ")!=kwsys_stl::string::npos)) + { + this->Features.HasSSE2 = true; + } + if ((cpuflags.find(" APIC ")!=kwsys_stl::string::npos)) + { + this->Features.HasAPIC = true; + } + if ((cpuflags.find(" CMOV ")!=kwsys_stl::string::npos)) + { + this->Features.HasCMOV = true; + } + if ((cpuflags.find(" MTRR ")!=kwsys_stl::string::npos)) + { + this->Features.HasMTRR = true; + } + if ((cpuflags.find(" ACPI ")!=kwsys_stl::string::npos)) + { + this->Features.HasACPI = true; + } + } + delete[] buf; } // brand string @@ -4059,13 +4138,12 @@ kwsys_stl::string SystemInformationImplementation::RunProcess(kwsys_stl::vector< char* data = NULL; int length; double timeout = 255; + int pipe; // pipe id as returned by kwsysProcess_WaitForData() - while(kwsysProcess_WaitForData(gp,&data,&length,&timeout)) // wait for 1s + while( ( pipe = kwsysProcess_WaitForData(gp,&data,&length,&timeout), + (pipe == kwsysProcess_Pipe_STDOUT || pipe == kwsysProcess_Pipe_STDERR) ) ) // wait for 1s { - for(int i=0;iCPUSpeedInMHz = (float) k; #endif +#if defined(CPU_SSE) + ctrl[0] = CTL_MACHDEP; + ctrl[1] = CPU_SSE; + + if (sysctl(ctrl, 2, &k, &sz, NULL, 0) != 0) + { + return false; + } + + this->Features.HasSSE = (k > 0); +#endif + +#if defined(CPU_SSE2) + ctrl[0] = CTL_MACHDEP; + ctrl[1] = CPU_SSE2; + + if (sysctl(ctrl, 2, &k, &sz, NULL, 0) != 0) + { + return false; + } + + this->Features.HasSSE2 = (k > 0); +#endif + +#if defined(CPU_CPUVENDOR) + ctrl[0] = CTL_MACHDEP; + ctrl[1] = CPU_CPUVENDOR; + char vbuf[25]; + ::memset(vbuf, 0, sizeof(vbuf)); + sz = sizeof(vbuf) - 1; + if (sysctl(ctrl, 2, vbuf, &sz, NULL, 0) != 0) + { + return false; + } + + this->ChipID.Vendor = vbuf; + this->FindManufacturer(); +#endif + return true; #else return false; -- cgit v0.12 From 3367d0cc7fe50e6b6fc06c85c8c38c683c1d3805 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sat, 12 Jan 2013 00:01:19 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index c71ba21..36a3204 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130111) +set(CMake_VERSION_TWEAK 20130112) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 9822f8c931c39b28a587cf48b5314431386d50ea Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sun, 13 Jan 2013 00:01:16 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 36a3204..14514c4 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130112) +set(CMake_VERSION_TWEAK 20130113) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 1da75022bbe3239e028fe73d94dfae724ad25a7f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 23 Dec 2012 19:00:18 +0100 Subject: Don't include generator expressions in old-style link handling. Don't add generator expressions to variables which are used for CMP0003, CMP0004, and the old-style _LIB_DEPENDS content. They will not be evaluated when read anyway and would probably confuse the code reading them. This makes it legitimate to use target_link_libraries with generator expressions as arguments. --- Source/cmTarget.cxx | 13 +++++++++++++ Source/cmTargetLinkLibrariesCommand.h | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9b50b8e..51512de 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2233,6 +2233,14 @@ static std::string targetNameGenex(const char *lib) } //---------------------------------------------------------------------------- +static bool isGeneratorExpression(const std::string &lib) +{ + const std::string::size_type openpos = lib.find("$<"); + return (openpos != std::string::npos) + && (lib.find(">", openpos) != std::string::npos); +} + +//---------------------------------------------------------------------------- void cmTarget::AddLinkLibrary(cmMakefile& mf, const char *target, const char* lib, LinkLibraryType llt) @@ -2254,6 +2262,11 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, llt).c_str()); } + if (isGeneratorExpression(lib)) + { + return; + } + cmTarget::LibraryID tmp; tmp.first = lib; tmp.second = llt; diff --git a/Source/cmTargetLinkLibrariesCommand.h b/Source/cmTargetLinkLibrariesCommand.h index 8e5823c..34fe54c 100644 --- a/Source/cmTargetLinkLibrariesCommand.h +++ b/Source/cmTargetLinkLibrariesCommand.h @@ -13,6 +13,7 @@ #define cmTargetLinkLibrariesCommand_h #include "cmCommand.h" +#include "cmDocumentGeneratorExpressions.h" /** \class cmTargetLinkLibrariesCommand * \brief Specify a list of libraries to link into executables. @@ -141,6 +142,12 @@ public: "However, if two archives are really so interdependent they should " "probably be combined into a single archive." ")" + "\n" + "Arguments to target_link_libraries may use \"generator expressions\" " + "with the syntax \"$<...>\". Note however, that generator expressions " + "will not be used in OLD handling of CMP0003 or CMP0004." + "\n" + CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS ; } -- cgit v0.12 From 7c7b94f21ffa6f3bda054d5e11bd09b13155c04e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 13 Jan 2013 10:04:40 +0100 Subject: Document the use of generator expressions in new commands. --- Source/cmTargetCompileDefinitionsCommand.h | 3 +++ Source/cmTargetIncludeDirectoriesCommand.h | 3 +++ Source/cmTargetPropCommandBase.h | 1 + 3 files changed, 7 insertions(+) diff --git a/Source/cmTargetCompileDefinitionsCommand.h b/Source/cmTargetCompileDefinitionsCommand.h index 707610e..4b066b7a 100644 --- a/Source/cmTargetCompileDefinitionsCommand.h +++ b/Source/cmTargetCompileDefinitionsCommand.h @@ -69,6 +69,9 @@ public: "INTERFACE_COMPILE_DEFINITIONS from. " "Repeated calls for the same append items in the order called." "\n" + "Arguments to target_compile_definitions may use \"generator " + "expressions\" with the syntax \"$<...>\". " + CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS ; } diff --git a/Source/cmTargetIncludeDirectoriesCommand.h b/Source/cmTargetIncludeDirectoriesCommand.h index c1957d6..90e039c 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.h +++ b/Source/cmTargetIncludeDirectoriesCommand.h @@ -73,6 +73,9 @@ public: "directories must be absolute paths, not relative paths. " "Repeated calls for the same append items in the order called." "\n" + "Arguments to target_include_directories may use \"generator " + "expressions\" with the syntax \"$<...>\". " + CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS ; } diff --git a/Source/cmTargetPropCommandBase.h b/Source/cmTargetPropCommandBase.h index 90e3bbb..e757f9d 100644 --- a/Source/cmTargetPropCommandBase.h +++ b/Source/cmTargetPropCommandBase.h @@ -14,6 +14,7 @@ #define cmTargetPropCommandBase_h #include "cmCommand.h" +#include "cmDocumentGeneratorExpressions.h" class cmTarget; -- cgit v0.12 From 2bee6f5ba5b3f33817cc00e056a7df60d05c9399 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 19 Nov 2012 23:56:12 +0100 Subject: Add the TARGET_DEFINED generator expression This tests whether the parameter is a usable target. --- Source/cmDocumentGeneratorExpressions.h | 1 + Source/cmGeneratorExpressionEvaluator.cxx | 18 ++++++++++++++++++ .../target_compile_definitions/CMakeLists.txt | 2 ++ .../target_compile_definitions/consumer.cpp | 8 ++++++++ 4 files changed, 29 insertions(+) diff --git a/Source/cmDocumentGeneratorExpressions.h b/Source/cmDocumentGeneratorExpressions.h index b8889ac..fa21907 100644 --- a/Source/cmDocumentGeneratorExpressions.h +++ b/Source/cmDocumentGeneratorExpressions.h @@ -37,6 +37,7 @@ "target in the same buildsystem. Expands to the empty string " \ "otherwise.\n" \ " $ = main file (.exe, .so.1.2, .a)\n" \ + " $ = '1' if tgt is a target, else '0'\n" \ " $ = file used to link (.a, .lib, .so)\n" \ " $ = file with soname (.so.3)\n" \ "where \"tgt\" is the name of a target. " \ diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index f4e4131..8e40815a 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -289,6 +289,22 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode } configurationTestNode; +static const struct TargetDefinedNode : public cmGeneratorExpressionNode +{ + TargetDefinedNode() {} + + virtual int NumExpectedParameters() const { return 1; } + + std::string Evaluate(const std::vector ¶meters, + cmGeneratorExpressionContext *context, + const GeneratorExpressionContent *, + cmGeneratorExpressionDAGChecker *) const + { + return context->Makefile->FindTargetToUse(parameters.front().c_str()) + ? "1" : "0"; + } +} targetDefinedNode; + //---------------------------------------------------------------------------- static const char* targetPropertyTransitiveWhitelist[] = { "INTERFACE_INCLUDE_DIRECTORIES" @@ -702,6 +718,8 @@ cmGeneratorExpressionNode* GetNode(const std::string &identifier) return &buildInterfaceNode; else if (identifier == "INSTALL_INTERFACE") return &installInterfaceNode; + else if (identifier == "TARGET_DEFINED") + return &targetDefinedNode; return 0; } diff --git a/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt index 84a23ef..a37c597 100644 --- a/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt +++ b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt @@ -23,4 +23,6 @@ add_executable(consumer target_compile_definitions(consumer PRIVATE target_compile_definitions importedlib + $<$:SHOULD_NOT_BE_DEFINED> + $<$:SHOULD_BE_DEFINED> ) diff --git a/Tests/CMakeCommands/target_compile_definitions/consumer.cpp b/Tests/CMakeCommands/target_compile_definitions/consumer.cpp index e3788dd..1ef657d 100644 --- a/Tests/CMakeCommands/target_compile_definitions/consumer.cpp +++ b/Tests/CMakeCommands/target_compile_definitions/consumer.cpp @@ -15,4 +15,12 @@ #error Expected MY_IMPORTEDINTERFACE_DEFINE #endif +#ifdef SHOULD_NOT_BE_DEFINED +#error Unexpected SHOULD_NOT_BE_DEFINED +#endif + +#ifndef SHOULD_BE_DEFINED +#error Expected SHOULD_BE_DEFINED +#endif + int main() { return 0; } -- cgit v0.12 From 36480eaf5c08c6f594f53d290df72ab42c29ba69 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Mon, 14 Jan 2013 00:01:23 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 14514c4..1660680 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130113) +set(CMake_VERSION_TWEAK 20130114) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 4ba0ac7be4bbe38a7cb3334504e69db039288ad8 Mon Sep 17 00:00:00 2001 From: KWSys Robot Date: Mon, 14 Jan 2013 09:26:01 -0500 Subject: KWSys 2013-01-14 (6fa1c99f) Extract upstream KWSys using the following shell commands. $ git archive --prefix=upstream-kwsys/ 6fa1c99f | tar x $ git shortlog --no-merges --abbrev=8 --format='%h %s' 608d6b47..6fa1c99f Brad King (1): 84827cc1 Process: Avoid argv[0]==NULL from parsing empty command line Rolf Eike Beer (8): e041cd66 SystemInformation: factor out QueryMemoryBySysconf() ea850fa0 SystemInformation: factor out QueryProcessorBySysconf() 57f06d49 SystemInformation: count processors with sysconf() on Solaris c6057a06 SystemInformation: fix "Multi-character character constant" 5a27bd4f SystemInformation: make IsHyperThreadingSupported() return bool 342c0ad2 SystemInformation: query memory size with sysconf() on Solaris f0b857c1 SystemInformation: cache result of IsHyperThreadingSupported() ab0c2a09 SystemInformation: try using assembler with BorlandC Change-Id: I072371ed35eed892a5ef62a9e9e6cad734e961d9 --- CMakeLists.txt | 16 +++++++ ProcessUNIX.c | 5 +- SystemInformation.cxx | 118 ++++++++++++++++++++++++++++++++-------------- kwsysPlatformTestsCXX.cxx | 27 +++++++++++ 4 files changed, 129 insertions(+), 37 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5df5a74..124b8ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -574,6 +574,8 @@ IF(KWSYS_USE_SystemTools) ENDIF() IF(KWSYS_USE_SystemInformation) + SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY + COMPILE_DEFINITIONS SIZEOF_VOID_P=${CMAKE_SIZEOF_VOID_P}) IF(NOT CYGWIN) INCLUDE(CheckIncludeFiles) CHECK_INCLUDE_FILES("sys/types.h;ifaddrs.h" KWSYS_SYS_HAS_IFADDRS_H) @@ -638,6 +640,20 @@ IF(KWSYS_USE_SystemInformation) SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY COMPILE_DEFINITIONS KWSYS_CXX_HAS__ATOI64=1) ENDIF() + IF(BORLAND) + KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_BORLAND_ASM + "Checking whether Borland CXX compiler supports assembler instructions" DIRECT) + IF(KWSYS_CXX_HAS_BORLAND_ASM) + SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY + COMPILE_DEFINITIONS KWSYS_CXX_HAS_BORLAND_ASM=1) + KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_BORLAND_ASM_CPUID + "Checking whether Borland CXX compiler supports CPUID assembler instruction" DIRECT) + IF(KWSYS_CXX_HAS_BORLAND_ASM_CPUID) + SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY + COMPILE_DEFINITIONS KWSYS_CXX_HAS_BORLAND_ASM_CPUID=1) + ENDIF() + ENDIF() + ENDIF() IF(KWSYS_USE___INT64) SET_PROPERTY(SOURCE SystemInformation.cxx testSystemInformation.cxx APPEND PROPERTY COMPILE_DEFINITIONS KWSYS_USE___INT64=1) diff --git a/ProcessUNIX.c b/ProcessUNIX.c index 83838af..2db1254 100644 --- a/ProcessUNIX.c +++ b/ProcessUNIX.c @@ -418,9 +418,10 @@ int kwsysProcess_AddCommand(kwsysProcess* cp, char const* const* command) parse it. */ newCommands[cp->NumberOfCommands] = kwsysSystem_Parse_CommandForUnix(*command, 0); - if(!newCommands[cp->NumberOfCommands]) + if(!newCommands[cp->NumberOfCommands] || + !newCommands[cp->NumberOfCommands][0]) { - /* Out of memory. */ + /* Out of memory or no command parsed. */ free(newCommands); return 0; } diff --git a/SystemInformation.cxx b/SystemInformation.cxx index 59a9abe..b20d724 100644 --- a/SystemInformation.cxx +++ b/SystemInformation.cxx @@ -202,7 +202,7 @@ typedef struct rlimit ResourceLimitType; #define USE_CPUID_INTRINSICS 0 #endif -#if USE_ASM_INSTRUCTIONS || USE_CPUID_INTRINSICS +#if USE_ASM_INSTRUCTIONS || USE_CPUID_INTRINSICS || defined(KWSYS_CXX_HAS_BORLAND_ASM_CPUID) # define USE_CPUID 1 #else # define USE_CPUID 0 @@ -224,6 +224,7 @@ static bool call_cpuid(int select, int result[4]) return true; #else int tmp[4]; +#if defined(_MSC_VER) // Use SEH to determine CPUID presence __try { _asm { @@ -262,7 +263,24 @@ static bool call_cpuid(int select, int result[4]) return false; } - memcpy(result, tmp, sizeof(tmp)); + memcpy(result, tmp, sizeof(tmp)); +#elif defined(KWSYS_CXX_HAS_BORLAND_ASM_CPUID) + unsigned int a, b, c, d; + __asm { + mov EAX, select; + cpuid + mov a, EAX; + mov b, EBX; + mov c, ECX; + mov d, EDX; + } + + result[0] = a; + result[1] = b; + result[2] = c; + result[3] = d; +#endif + // The cpuid instruction succeeded. return true; #endif @@ -432,7 +450,7 @@ protected: int CPUCount(); unsigned char LogicalCPUPerPhysicalCPU(); unsigned char GetAPICId(); - unsigned int IsHyperThreadingSupported(); + bool IsHyperThreadingSupported(); static LongLong GetCyclesDifference(DELAY_FUNC, unsigned int); // For Linux and Cygwin, /proc/cpuinfo formats are slightly different @@ -456,7 +474,8 @@ protected: kwsys_stl::string SysCtlBuffer; // For Solaris - bool QuerySolarisInfo(); + bool QuerySolarisMemory(); + bool QuerySolarisProcessor(); kwsys_stl::string ParseValueFromKStat(const char* arguments); kwsys_stl::string RunProcess(kwsys_stl::vector args); @@ -481,9 +500,11 @@ protected: //For AIX bool QueryAIXMemory(); + bool QueryProcessorBySysconf(); bool QueryProcessor(); // Evaluate the memory information. + bool QueryMemoryBySysconf(); bool QueryMemory(); size_t TotalVirtualMemory; size_t AvailableVirtualMemory; @@ -1287,7 +1308,7 @@ void SystemInformationImplementation::RunCPUCheck() #elif defined(__APPLE__) this->ParseSysCtl(); #elif defined (__SVR4) && defined (__sun) - this->QuerySolarisInfo(); + this->QuerySolarisProcessor(); #elif defined(__HAIKU__) this->QueryHaikuInfo(); #elif defined(__QNX__) @@ -1313,7 +1334,7 @@ void SystemInformationImplementation::RunMemoryCheck() #if defined(__APPLE__) this->ParseSysCtl(); #elif defined (__SVR4) && defined (__sun) - this->QuerySolarisInfo(); + this->QuerySolarisMemory(); #elif defined(__HAIKU__) this->QueryHaikuInfo(); #elif defined(__QNX__) @@ -3016,7 +3037,7 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile() return true; } -bool SystemInformationImplementation::QueryProcessor() +bool SystemInformationImplementation::QueryProcessorBySysconf() { #if defined(_SC_NPROC_ONLN) && !defined(_SC_NPROCESSORS_ONLN) // IRIX names this slightly different @@ -3039,6 +3060,11 @@ bool SystemInformationImplementation::QueryProcessor() #endif } +bool SystemInformationImplementation::QueryProcessor() +{ + return this->QueryProcessorBySysconf(); +} + /** Get total system RAM in units of KiB. */ @@ -3559,8 +3585,7 @@ bool SystemInformationImplementation::QueryAIXMemory() #endif } -/** Query for the memory status */ -bool SystemInformationImplementation::QueryMemory() +bool SystemInformationImplementation::QueryMemoryBySysconf() { #if defined(_SC_PHYS_PAGES) && defined(_SC_PAGESIZE) // Assume the mmap() granularity as returned by _SC_PAGESIZE is also @@ -3597,6 +3622,12 @@ bool SystemInformationImplementation::QueryMemory() #endif } +/** Query for the memory status */ +bool SystemInformationImplementation::QueryMemory() +{ + return this->QueryMemoryBySysconf(); +} + /** */ size_t SystemInformationImplementation::GetTotalVirtualMemory() { @@ -3729,8 +3760,13 @@ unsigned char SystemInformationImplementation::LogicalCPUPerPhysicalCPU(void) /** Works only for windows */ -unsigned int SystemInformationImplementation::IsHyperThreadingSupported() +bool SystemInformationImplementation::IsHyperThreadingSupported() { + if (this->Features.ExtendedFeatures.SupportsHyperthreading) + { + return true; + } + #if USE_CPUID int Regs[4] = { 0, 0, 0, 0 }, VendorId[4] = { 0, 0, 0, 0 }; @@ -3748,13 +3784,15 @@ unsigned int SystemInformationImplementation::IsHyperThreadingSupported() if (((Regs[0] & FAMILY_ID) == PENTIUM4_ID) || (Regs[0] & EXT_FAMILY_ID)) { - if (VendorId[1] == 'uneG') + if (VendorId[1] == 0x756e6547) // 'uneG' { - if (VendorId[3] == 'Ieni') + if (VendorId[3] == 0x49656e69) // 'Ieni' { - if (VendorId[2] == 'letn') + if (VendorId[2] == 0x6c65746e) // 'letn' { - return(Regs[3] & HT_BIT); // Genuine Intel with hyper-Threading technology + // Genuine Intel with hyper-Threading technology + this->Features.ExtendedFeatures.SupportsHyperthreading = ((Regs[3] & HT_BIT) != 0); + return this->Features.ExtendedFeatures.SupportsHyperthreading; } } } @@ -4251,16 +4289,40 @@ kwsys_stl::string SystemInformationImplementation::ParseValueFromKStat(const cha return value; } - /** Querying for system information from Solaris */ -bool SystemInformationImplementation::QuerySolarisInfo() +bool SystemInformationImplementation::QuerySolarisMemory() { - // Parse values - this->NumberOfPhysicalCPU = static_cast( - atoi(this->ParseValueFromKStat("-n syste_misc -s ncpus").c_str())); - this->NumberOfLogicalCPU = this->NumberOfPhysicalCPU; - this->Features.ExtendedFeatures.LogicalProcessorsPerPhysical = 1; +#if defined (__SVR4) && defined (__sun) + // Solaris allows querying this value by sysconf, but if this is + // a 32 bit process on a 64 bit host the returned memory will be + // limited to 4GiB. So if this is a 32 bit process or if the sysconf + // method fails use the kstat interface. +#if SIZEOF_VOID_P == 8 + if (this->QueryMemoryBySysconf()) + { + return true; + } +#endif + char* tail; + unsigned long totalMemory = + strtoul(this->ParseValueFromKStat("-s physmem").c_str(),&tail,0); + this->TotalPhysicalMemory = totalMemory/128; + + return true; +#else + return false; +#endif +} + +bool SystemInformationImplementation::QuerySolarisProcessor() +{ + if (!this->QueryProcessorBySysconf()) + { + return false; + } + + // Parse values this->CPUSpeedInMHz = static_cast(atoi(this->ParseValueFromKStat("-s clock_MHz").c_str())); // Chip family @@ -4277,20 +4339,6 @@ bool SystemInformationImplementation::QuerySolarisInfo() this->FindManufacturer(); } - // Cache size - this->Features.L1CacheSize = 0; - this->Features.L2CacheSize = 0; - - char* tail; - unsigned long totalMemory = - strtoul(this->ParseValueFromKStat("-s physmem").c_str(),&tail,0); - this->TotalPhysicalMemory = totalMemory/128; - - // Undefined values (for now at least) - this->TotalVirtualMemory = 0; - this->AvailablePhysicalMemory = 0; - this->AvailableVirtualMemory = 0; - return true; } diff --git a/kwsysPlatformTestsCXX.cxx b/kwsysPlatformTestsCXX.cxx index ae58703..48976c4 100644 --- a/kwsysPlatformTestsCXX.cxx +++ b/kwsysPlatformTestsCXX.cxx @@ -580,3 +580,30 @@ int main() } } #endif + +#ifdef TEST_KWSYS_CXX_HAS_BORLAND_ASM +int main() +{ + int a = 1; + __asm { + xor EBX, EBX; + mov a, EBX; + } + + return a; +} +#endif + +#ifdef TEST_KWSYS_CXX_HAS_BORLAND_ASM_CPUID +int main() +{ + int a = 0; + __asm { + xor EAX, EAX; + cpuid; + mov a, EAX; + } + + return a; +} +#endif -- cgit v0.12 From cf3faacad2aff9ac3c9f2d407b1823a75939160e Mon Sep 17 00:00:00 2001 From: "Yury G. Kudryashov" Date: Fri, 11 Jan 2013 12:42:34 +0400 Subject: Automoc: Fix automoc for OBJECT libraries. Before this patch, add_library(obj OBJECT helper.cpp) add_executable(tgt $) didn't run automoc on helper.cpp. --- Source/cmGlobalGenerator.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index d030aa7..b431705 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1075,7 +1075,8 @@ void cmGlobalGenerator::CreateAutomocTargets() if(target.GetType() == cmTarget::EXECUTABLE || target.GetType() == cmTarget::STATIC_LIBRARY || target.GetType() == cmTarget::SHARED_LIBRARY || - target.GetType() == cmTarget::MODULE_LIBRARY) + target.GetType() == cmTarget::MODULE_LIBRARY || + target.GetType() == cmTarget::OBJECT_LIBRARY) { if(target.GetPropertyAsBool("AUTOMOC") && !target.IsImported()) { -- cgit v0.12 From 0e35cac3d06bb89faa89ed4bf425f0978e828321 Mon Sep 17 00:00:00 2001 From: "Yury G. Kudryashov" Date: Fri, 11 Jan 2013 13:40:13 +0400 Subject: Automoc: add OBJECT library to QtAutomoc test --- Tests/QtAutomoc/CMakeLists.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Tests/QtAutomoc/CMakeLists.txt b/Tests/QtAutomoc/CMakeLists.txt index 5e3686d..855fcf0 100644 --- a/Tests/QtAutomoc/CMakeLists.txt +++ b/Tests/QtAutomoc/CMakeLists.txt @@ -13,11 +13,14 @@ add_definitions(-DFOO -DSomeDefine="Barx") # enable relaxed mode so automoc can handle all the special cases: set(CMAKE_AUTOMOC_RELAXED_MODE TRUE) -# create an executable and a library target, both requiring automoc: +# create an executable and two library targets, each requiring automoc: add_library(codeeditorLib STATIC codeeditor.cpp) -add_executable(foo main.cpp calwidget.cpp foo.cpp blub.cpp bar.cpp abc.cpp xyz.cpp yaf.cpp private_slot.cpp) +add_library(privateSlot OBJECT private_slot.cpp) -set_target_properties(foo codeeditorLib PROPERTIES AUTOMOC TRUE) +add_executable(foo main.cpp calwidget.cpp foo.cpp blub.cpp bar.cpp abc.cpp + xyz.cpp yaf.cpp $) + +set_target_properties(foo codeeditorLib privateSlot PROPERTIES AUTOMOC TRUE) target_link_libraries(foo codeeditorLib ${QT_LIBRARIES} ) -- cgit v0.12 From 3a40a8adf36c25321895c0ba12484d1e2989be6b Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Tue, 15 Jan 2013 00:01:13 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 1660680..1e7fe50 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130114) +set(CMake_VERSION_TWEAK 20130115) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 7171fd0a903e71486e1d1cebc36aeaa2d2c71e8c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 5 Dec 2012 14:59:39 +0100 Subject: Add a way to check INTERFACE user property compatibility. --- Source/cmTarget.cxx | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++ Source/cmTarget.h | 2 ++ Source/cmake.cxx | 7 ++++++ Source/cmake.h | 2 ++ 4 files changed, 81 insertions(+) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9b50b8e..6f3f638 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -892,6 +892,19 @@ void cmTarget::DefineProperties(cmake *cm) "requirement for their INTERFACE_POSITION_INDEPENDENT_CODE property."); cm->DefineProperty + ("COMPATIBLE_INTERFACE_BOOL", cmProperty::TARGET, + "Properties which must be compatible with their link interface", + "The COMPATIBLE_INTERFACE_BOOL property may contain a list of properties" + "for this target which must be consistent when evaluated as a boolean " + "in the INTERFACE of all linked dependencies. For example, if a " + "property \"FOO\" appears in the list, then the \"INTERFACE_FOO\" " + "property content in all dependencies must be consistent with each " + "other, and with the \"FOO\" property in this target. " + "Consistency in this sense has the meaning that if the property is set," + "then it must have the same boolean value as all others, and if the " + "property is not set, then it is ignored."); + + cm->DefineProperty ("POST_INSTALL_SCRIPT", cmProperty::TARGET, "Deprecated install support.", "The PRE_INSTALL_SCRIPT and POST_INSTALL_SCRIPT properties are the " @@ -5299,6 +5312,58 @@ std::string cmTarget::CheckCMP0004(std::string const& item) } //---------------------------------------------------------------------------- +void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, + const char* config) +{ + const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); + + std::set emitted; + + for(cmComputeLinkInformation::ItemVector::const_iterator li = + deps.begin(); + li != deps.end(); ++li) + { + if (!li->Target) + { + continue; + } + const char *prop = li->Target->GetProperty("COMPATIBLE_INTERFACE_BOOL"); + if (!prop) + { + continue; + } + + std::vector props; + cmSystemTools::ExpandListArgument(prop, props); + + for(std::vector::iterator pi = props.begin(); + pi != props.end(); ++pi) + { + if (this->Makefile->GetCMakeInstance() + ->GetIsPropertyDefined(pi->c_str(), + cmProperty::TARGET)) + { + cmOStringStream e; + e << "Target \"" << li->Target->GetName() << "\" has property \"" + << *pi << "\" listed in its COMPATIBLE_INTERFACE_BOOL property. " + "This is not allowed. Only user-defined properties may appear " + "listed in the COMPATIBLE_INTERFACE_BOOL property."; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + return; + } + if(emitted.insert(*pi).second) + { + this->GetLinkInterfaceDependentBoolProperty(*pi, config); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + } + } + } +} + +//---------------------------------------------------------------------------- cmComputeLinkInformation* cmTarget::GetLinkInformation(const char* config, cmTarget *head) { @@ -5319,6 +5384,11 @@ cmTarget::GetLinkInformation(const char* config, cmTarget *head) info = 0; } + if (info) + { + this->CheckPropertyCompatibility(info, config); + } + // Store the information for this configuration. cmTargetLinkInformationMap::value_type entry(key, info); i = this->LinkInformation.insert(entry).first; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index b4d053d..0963c5c 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -626,6 +626,8 @@ private: cmTarget *head); cmTargetLinkInformationMap LinkInformation; + void CheckPropertyCompatibility(cmComputeLinkInformation *info, + const char* config); bool ComputeLinkInterface(const char* config, LinkInterface& iface, cmTarget *head); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index a44c825..bbc7f1f 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -3552,6 +3552,13 @@ void cmake::DefineProperty(const char *name, cmProperty::ScopeType scope, chained); } +bool cmake::GetIsPropertyDefined(const char *name, + cmProperty::ScopeType scope) +{ + return this->PropertyDefinitions[scope].find(name) != + this->PropertyDefinitions[scope].end(); +} + cmPropertyDefinition *cmake ::GetPropertyDefinition(const char *name, cmProperty::ScopeType scope) diff --git a/Source/cmake.h b/Source/cmake.h index e5aa076..f6fe0d6 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -341,6 +341,8 @@ class cmake bool chain = false, const char *variableGroup = 0); + bool GetIsPropertyDefined(const char *name, cmProperty::ScopeType scope); + // get property definition cmPropertyDefinition *GetPropertyDefinition (const char *name, cmProperty::ScopeType scope); -- cgit v0.12 From b279f2b43180b6c55dd3361c2380f7ed3c998109 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 13 Jan 2013 09:39:29 +0100 Subject: Strip consecutive semicolons when preprocessing genex strings. --- Source/cmGeneratorExpression.cxx | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index d306dee..78ae8f2 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -148,6 +148,38 @@ cmCompiledGeneratorExpression::~cmCompiledGeneratorExpression() } //---------------------------------------------------------------------------- +static std::string stripEmptyListElements(const std::string &input) +{ + std::string result; + + const char *c = input.c_str(); + bool skipSemiColons = true; + for ( ; *c; ++c) + { + if(c[0] == ';') + { + if(skipSemiColons) + { + continue; + } + skipSemiColons = true; + } + else + { + skipSemiColons = false; + } + result += *c; + } + + if (!result.empty() && *(result.end() - 1) == ';') + { + result.resize(result.size() - 1); + } + + return result; +} + +//---------------------------------------------------------------------------- static std::string stripAllGeneratorExpressions(const std::string &input) { std::string result; @@ -186,7 +218,7 @@ static std::string stripAllGeneratorExpressions(const std::string &input) lastPos = pos; } result += input.substr(lastPos); - return result; + return stripEmptyListElements(result); } //---------------------------------------------------------------------------- @@ -247,7 +279,7 @@ static std::string stripExportInterface(const std::string &input, } result += input.substr(lastPos); - return result; + return stripEmptyListElements(result); } //---------------------------------------------------------------------------- -- cgit v0.12 From f623d37a9558336af208a4fb5db232b28b56cb82 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 13 Jan 2013 09:42:07 +0100 Subject: Don't write a comment in the export file without the code. --- Source/cmExportFileGenerator.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 94e24c7..91de200 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -665,6 +665,10 @@ cmExportFileGenerator void cmExportFileGenerator::GenerateMissingTargetsCheckCode(std::ostream& os, const std::vector& missingTargets) { + if (missingTargets.empty()) + { + return; + } os << "# Make sure the targets which have been exported in some other \n" "# export set exist.\n"; for(unsigned int i=0; i Date: Sun, 13 Jan 2013 09:42:47 +0100 Subject: Only generate one check per missing target. --- Source/cmExportFileGenerator.cxx | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 91de200..a2d6961 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -671,19 +671,23 @@ void cmExportFileGenerator::GenerateMissingTargetsCheckCode(std::ostream& os, } os << "# Make sure the targets which have been exported in some other \n" "# export set exist.\n"; + std::set emitted; for(unsigned int i=0; i Date: Sun, 13 Jan 2013 09:44:52 +0100 Subject: Move the exported check for dependencies of targets Check only once, in the Config.cmake file, instead of once in each Config-.cmake file. --- Source/cmExportBuildFileGenerator.cxx | 11 +++++------ Source/cmExportBuildFileGenerator.h | 3 ++- Source/cmExportFileGenerator.cxx | 5 +++-- Source/cmExportFileGenerator.h | 6 ++++-- Source/cmExportInstallFileGenerator.cxx | 16 +++++++++------- Source/cmExportInstallFileGenerator.h | 6 ++++-- 6 files changed, 27 insertions(+), 20 deletions(-) diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 29f6743..ad61803 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -74,16 +74,16 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) this->GenerateInterfaceProperties(te, os, properties); } - this->GenerateMissingTargetsCheckCode(os, missingTargets); - // Generate import file content for each configuration. for(std::vector::const_iterator ci = this->Configurations.begin(); ci != this->Configurations.end(); ++ci) { - this->GenerateImportConfig(os, ci->c_str()); + this->GenerateImportConfig(os, ci->c_str(), missingTargets); } + this->GenerateMissingTargetsCheckCode(os, missingTargets); + return true; } @@ -91,7 +91,8 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) void cmExportBuildFileGenerator ::GenerateImportTargetsConfig(std::ostream& os, - const char* config, std::string const& suffix) + const char* config, std::string const& suffix, + std::vector &missingTargets) { for(std::vector::const_iterator tei = this->Exports->begin(); @@ -104,7 +105,6 @@ cmExportBuildFileGenerator if(!properties.empty()) { // Get the rest of the target details. - std::vector missingTargets; this->SetImportDetailProperties(config, suffix, target, properties, missingTargets); this->SetImportLinkInterface(config, suffix, @@ -119,7 +119,6 @@ cmExportBuildFileGenerator // properties); // Generate code in the export file. - this->GenerateMissingTargetsCheckCode(os, missingTargets); this->GenerateImportPropertyCode(os, config, target, properties); } } diff --git a/Source/cmExportBuildFileGenerator.h b/Source/cmExportBuildFileGenerator.h index 726537b..5e1be16 100644 --- a/Source/cmExportBuildFileGenerator.h +++ b/Source/cmExportBuildFileGenerator.h @@ -44,7 +44,8 @@ protected: virtual bool GenerateMainFile(std::ostream& os); virtual void GenerateImportTargetsConfig(std::ostream& os, const char* config, - std::string const& suffix); + std::string const& suffix, + std::vector &missingTargets); virtual void HandleMissingTarget(std::string& link_libs, std::vector& missingTargets, cmMakefile* mf, diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index a2d6961..fc78eeb 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -107,7 +107,8 @@ bool cmExportFileGenerator::GenerateImportFile() //---------------------------------------------------------------------------- void cmExportFileGenerator::GenerateImportConfig(std::ostream& os, - const char* config) + const char* config, + std::vector &missingTargets) { // Construct the property configuration suffix. std::string suffix = "_"; @@ -121,7 +122,7 @@ void cmExportFileGenerator::GenerateImportConfig(std::ostream& os, } // Generate the per-config target information. - this->GenerateImportTargetsConfig(os, config, suffix); + this->GenerateImportTargetsConfig(os, config, suffix, missingTargets); } //---------------------------------------------------------------------------- diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 4d97a63..8620dd1 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -47,7 +47,8 @@ protected: // Generate per-configuration target information to the given output // stream. - void GenerateImportConfig(std::ostream& os, const char* config); + void GenerateImportConfig(std::ostream& os, const char* config, + std::vector &missingTargets); // Methods to implement export file code generation. void GenerateImportHeaderCode(std::ostream& os, const char* config = 0); @@ -85,7 +86,8 @@ protected: /** Each subclass knows where the target files are located. */ virtual void GenerateImportTargetsConfig(std::ostream& os, const char* config, - std::string const& suffix) = 0; + std::string const& suffix, + std::vector &missingTargets) = 0; /** Each subclass knows how to deal with a target that is missing from an * export set. */ diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 68881a1..bffa2b6 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -93,7 +93,6 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) this->GenerateInterfaceProperties(te, os, properties); } - this->GenerateMissingTargetsCheckCode(os, missingTargets); // Now load per-configuration properties for them. os << "# Load information for each installed configuration.\n" @@ -111,17 +110,21 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) ci = this->Configurations.begin(); ci != this->Configurations.end(); ++ci) { - if(!this->GenerateImportFileConfig(ci->c_str())) + if(!this->GenerateImportFileConfig(ci->c_str(), missingTargets)) { result = false; } } + + this->GenerateMissingTargetsCheckCode(os, missingTargets); + return result; } //---------------------------------------------------------------------------- bool -cmExportInstallFileGenerator::GenerateImportFileConfig(const char* config) +cmExportInstallFileGenerator::GenerateImportFileConfig(const char* config, + std::vector &missingTargets) { // Skip configurations not enabled for this export. if(!this->IEGen->InstallsForConfig(config)) @@ -161,7 +164,7 @@ cmExportInstallFileGenerator::GenerateImportFileConfig(const char* config) this->GenerateImportHeaderCode(os, config); // Generate the per-config target information. - this->GenerateImportConfig(os, config); + this->GenerateImportConfig(os, config, missingTargets); // End with the import file footer. this->GenerateImportFooterCode(os); @@ -176,7 +179,8 @@ cmExportInstallFileGenerator::GenerateImportFileConfig(const char* config) void cmExportInstallFileGenerator ::GenerateImportTargetsConfig(std::ostream& os, - const char* config, std::string const& suffix) + const char* config, std::string const& suffix, + std::vector &missingTargets) { // Add code to compute the installation prefix relative to the // import file location. @@ -225,7 +229,6 @@ cmExportInstallFileGenerator if(!properties.empty()) { // Get the rest of the target details. - std::vector missingTargets; this->SetImportDetailProperties(config, suffix, te->Target, properties, missingTargets); @@ -240,7 +243,6 @@ cmExportInstallFileGenerator // properties); // Generate code in the export file. - this->GenerateMissingTargetsCheckCode(os, missingTargets); this->GenerateImportPropertyCode(os, config, te->Target, properties); this->GenerateImportedFileChecksCode(os, te->Target, properties, importedLocations); diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h index e719ecc..e187749 100644 --- a/Source/cmExportInstallFileGenerator.h +++ b/Source/cmExportInstallFileGenerator.h @@ -56,7 +56,8 @@ protected: virtual bool GenerateMainFile(std::ostream& os); virtual void GenerateImportTargetsConfig(std::ostream& os, const char* config, - std::string const& suffix); + std::string const& suffix, + std::vector &missingTargets); virtual void HandleMissingTarget(std::string& link_libs, std::vector& missingTargets, cmMakefile* mf, @@ -72,7 +73,8 @@ protected: /** Generate a per-configuration file for the targets. */ - bool GenerateImportFileConfig(const char* config); + bool GenerateImportFileConfig(const char* config, + std::vector &missingTargets); /** Fill in properties indicating installed file locations. */ void SetImportLocationProperty(const char* config, -- cgit v0.12 From 6c828f9126453d27c45e1ca6113602fe9df8cbe2 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 13 Jan 2013 09:48:45 +0100 Subject: Move the exported check for file existence. Check only once, in the Config.cmake file, instead of once in each Config-.cmake file. --- Source/cmExportInstallFileGenerator.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index bffa2b6..7eed5ab 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -104,6 +104,8 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) << "ENDFOREACH(f)\n" << "\n"; + this->GenerateImportedFileCheckLoop(os); + // Generate an import file for each configuration. bool result = true; for(std::vector::const_iterator @@ -249,8 +251,6 @@ cmExportInstallFileGenerator } } - this->GenerateImportedFileCheckLoop(os); - // Cleanup the import prefix variable. if(!this->ImportPrefix.empty()) { -- cgit v0.12 From 1d47cd94f3748d287f676f3847d42f3674062dcd Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 12 Jan 2013 00:00:42 +0100 Subject: Add a test for the interfaces in targets exported from the build tree. --- Tests/ExportImport/Export/CMakeLists.txt | 1 + Tests/ExportImport/Import/A/CMakeLists.txt | 29 +++++++++++++---------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index 779d889..4f6ccd6 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -250,6 +250,7 @@ endif() # Export from build tree. export(TARGETS testExe1 testLib1 testLib2 testLib3 testExe2libImp testLib3Imp testLib3ImpDep + testSharedLibRequired testSharedLibDepends NAMESPACE bld_ FILE ExportBuildTree.cmake ) diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index abb2ab0..6a2e54c 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -159,22 +159,19 @@ endif() add_executable(deps_iface deps_iface.c) target_link_libraries(deps_iface testLibDepends) -set_property(TARGET deps_iface APPEND PROPERTY - COMPILE_DEFINITIONS - $ -) -set_property(TARGET deps_iface APPEND PROPERTY - INCLUDE_DIRECTORIES - $ -) +target_include_directories(deps_iface PRIVATE testLibDepends) +target_compile_definitions(deps_iface PRIVATE testLibDepends) add_executable(deps_shared_iface deps_shared_iface.cpp) target_link_libraries(deps_shared_iface testSharedLibDepends) -set_property(TARGET deps_shared_iface APPEND PROPERTY - COMPILE_DEFINITIONS - $ -) -set_property(TARGET deps_shared_iface APPEND PROPERTY - INCLUDE_DIRECTORIES - $ -) +target_include_directories(deps_shared_iface PRIVATE testSharedLibDepends) +target_compile_definitions(deps_shared_iface PRIVATE testSharedLibDepends) + +#----------------------------------------------------------------------------- +# Test that targets imported from the build tree have their dependencies +# evaluated correctly. The above already tests the same for the install tree. + +add_executable(deps_shared_iface2 deps_shared_iface.cpp) +target_link_libraries(deps_shared_iface2 bld_testSharedLibDepends) +target_include_directories(deps_shared_iface2 PRIVATE bld_testSharedLibDepends) +target_compile_definitions(deps_shared_iface2 PRIVATE bld_testSharedLibDepends) -- cgit v0.12 From 4ee872cb99f49ac5a95768da454f3313ba87182f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 12 Jan 2013 12:11:29 +0100 Subject: Make the BUILD_INTERFACE of export()ed targets work. The existing BUILD_INTERFACE code is executed at generate time, which is too late for export(). --- Source/cmExportBuildFileGenerator.cxx | 2 ++ Source/cmGlobalGenerator.cxx | 14 +------------ Source/cmTarget.cxx | 25 +++++++++++++++++++++++ Source/cmTarget.h | 3 +++ Tests/ExportImport/Export/CMakeLists.txt | 4 +++- Tests/ExportImport/Export/sublib/CMakeLists.txt | 6 ++++++ Tests/ExportImport/Export/sublib/subdir.cpp | 7 +++++++ Tests/ExportImport/Export/sublib/subdir.h | 12 +++++++++++ Tests/ExportImport/Import/A/CMakeLists.txt | 8 +++++--- Tests/ExportImport/Import/A/deps_shared_iface.cpp | 14 ++++++++++++- 10 files changed, 77 insertions(+), 18 deletions(-) create mode 100644 Tests/ExportImport/Export/sublib/CMakeLists.txt create mode 100644 Tests/ExportImport/Export/sublib/subdir.cpp create mode 100644 Tests/ExportImport/Export/sublib/subdir.h diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index ad61803..36c53dc 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -62,6 +62,8 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) cmTarget* te = *tei; this->GenerateImportTargetCode(os, te); + te->AppendBuildInterfaceIncludes(); + ImportPropertyMap properties; this->PopulateInterfaceProperty("INTERFACE_INCLUDE_DIRECTORIES", te, diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index d030aa7..d2baf53 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -941,19 +941,7 @@ void cmGlobalGenerator::Generate() for ( tit = targets->begin(); tit != targets->end(); ++ tit ) { - if (mf->IsOn("CMAKE_BUILD_INTERFACE_INCLUDES")) - { - const char *binDir = mf->GetStartOutputDirectory(); - const char *srcDir = mf->GetStartDirectory(); - const std::string dirs = std::string(binDir ? binDir : "") - + std::string(binDir ? ";" : "") - + std::string(srcDir ? srcDir : ""); - if (!dirs.empty()) - { - tit->second.AppendProperty("INTERFACE_INCLUDE_DIRECTORIES", - ("$").c_str()); - } - } + tit->second.AppendBuildInterfaceIncludes(); } } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9b50b8e..cf01f9f 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -150,6 +150,7 @@ cmTarget::cmTarget() this->DLLPlatform = false; this->IsApple = false; this->IsImportedTarget = false; + this->BuildInterfaceIncludesAppended = false; } //---------------------------------------------------------------------------- @@ -2655,6 +2656,30 @@ void cmTarget::AppendProperty(const char* prop, const char* value, } //---------------------------------------------------------------------------- +void cmTarget::AppendBuildInterfaceIncludes() +{ + if (this->BuildInterfaceIncludesAppended) + { + return; + } + this->BuildInterfaceIncludesAppended = true; + + if (this->Makefile->IsOn("CMAKE_BUILD_INTERFACE_INCLUDES")) + { + const char *binDir = this->Makefile->GetStartOutputDirectory(); + const char *srcDir = this->Makefile->GetStartDirectory(); + const std::string dirs = std::string(binDir ? binDir : "") + + std::string(binDir ? ";" : "") + + std::string(srcDir ? srcDir : ""); + if (!dirs.empty()) + { + this->AppendProperty("INTERFACE_INCLUDE_DIRECTORIES", + ("$").c_str()); + } + } +} + +//---------------------------------------------------------------------------- void cmTarget::InsertInclude(const cmMakefileIncludeDirectoriesEntry &entry, bool before) { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index b4d053d..48dde0a 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -490,6 +490,8 @@ public: void InsertInclude(const cmMakefileIncludeDirectoriesEntry &entry, bool before = false); + void AppendBuildInterfaceIncludes(); + void GetLinkDependentTargetsForProperty(const std::string &p, std::set &targets); bool IsNullImpliedByLinkLibraries(const std::string &p); @@ -611,6 +613,7 @@ private: mutable std::map > LinkDependentProperties; mutable std::set LinkImplicitNullProperties; + bool BuildInterfaceIncludesAppended; // Cache target output paths for each configuration. struct OutputInfo; diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index 4f6ccd6..e92dcd8 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -247,9 +247,11 @@ if(WIN32) install(TARGETS testLib5 RUNTIME DESTINATION bin) endif() +add_subdirectory(sublib) # For CMAKE_BUILD_INTERFACE_INCLUDES test. + # Export from build tree. export(TARGETS testExe1 testLib1 testLib2 testLib3 - testExe2libImp testLib3Imp testLib3ImpDep + testExe2libImp testLib3Imp testLib3ImpDep subdirlib testSharedLibRequired testSharedLibDepends NAMESPACE bld_ FILE ExportBuildTree.cmake diff --git a/Tests/ExportImport/Export/sublib/CMakeLists.txt b/Tests/ExportImport/Export/sublib/CMakeLists.txt new file mode 100644 index 0000000..2d11040 --- /dev/null +++ b/Tests/ExportImport/Export/sublib/CMakeLists.txt @@ -0,0 +1,6 @@ + +set(CMAKE_BUILD_INTERFACE_INCLUDES ON) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +add_library(subdirlib SHARED subdir.cpp) +generate_export_header(subdirlib) diff --git a/Tests/ExportImport/Export/sublib/subdir.cpp b/Tests/ExportImport/Export/sublib/subdir.cpp new file mode 100644 index 0000000..35b0743 --- /dev/null +++ b/Tests/ExportImport/Export/sublib/subdir.cpp @@ -0,0 +1,7 @@ + +#include "subdir.h" + +int SubDirObject::foo() +{ + return 0; +} diff --git a/Tests/ExportImport/Export/sublib/subdir.h b/Tests/ExportImport/Export/sublib/subdir.h new file mode 100644 index 0000000..3a4b73d --- /dev/null +++ b/Tests/ExportImport/Export/sublib/subdir.h @@ -0,0 +1,12 @@ + +#ifndef SUBDIR_H +#define SUBDIR_H + +#include "subdirlib_export.h" + +struct SUBDIRLIB_EXPORT SubDirObject +{ + int foo(); +}; + +#endif diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index 6a2e54c..72d11b6 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -172,6 +172,8 @@ target_compile_definitions(deps_shared_iface PRIVATE testSharedLibDepends) # evaluated correctly. The above already tests the same for the install tree. add_executable(deps_shared_iface2 deps_shared_iface.cpp) -target_link_libraries(deps_shared_iface2 bld_testSharedLibDepends) -target_include_directories(deps_shared_iface2 PRIVATE bld_testSharedLibDepends) -target_compile_definitions(deps_shared_iface2 PRIVATE bld_testSharedLibDepends) +target_link_libraries(deps_shared_iface2 bld_testSharedLibDepends bld_subdirlib) +target_include_directories(deps_shared_iface2 PRIVATE bld_testSharedLibDepends bld_subdirlib) +target_compile_definitions(deps_shared_iface2 + PRIVATE bld_testSharedLibDepends TEST_SUBDIR_LIB +) diff --git a/Tests/ExportImport/Import/A/deps_shared_iface.cpp b/Tests/ExportImport/Import/A/deps_shared_iface.cpp index 4f7eb23..14aac0a 100644 --- a/Tests/ExportImport/Import/A/deps_shared_iface.cpp +++ b/Tests/ExportImport/Import/A/deps_shared_iface.cpp @@ -2,10 +2,22 @@ #include "testSharedLibDepends.h" +#ifdef TEST_SUBDIR_LIB +#include "subdir.h" +#endif + int main(int,char **) { TestSharedLibDepends dep; TestSharedLibRequired req; - return dep.foo() + req.foo(); +#ifdef TEST_SUBDIR_LIB + SubDirObject sdo; +#endif + + return dep.foo() + req.foo() +#ifdef TEST_SUBDIR_LIB + + sdo.foo() +#endif + ; } -- cgit v0.12 From 522bdac14963acf7c147f5518ea51382b042bf96 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 12 Jan 2013 12:13:19 +0100 Subject: Export the INTERFACE_PIC property. --- Source/cmExportBuildFileGenerator.cxx | 2 ++ Source/cmExportFileGenerator.cxx | 12 ++++++++++++ Source/cmExportFileGenerator.h | 2 ++ Source/cmExportInstallFileGenerator.cxx | 2 ++ Tests/ExportImport/Export/CMakeLists.txt | 4 ++++ Tests/ExportImport/Import/A/CMakeLists.txt | 18 ++++++++++++++++++ Tests/ExportImport/Import/A/deps_shared_iface.cpp | 6 ++++++ 7 files changed, 46 insertions(+) diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 36c53dc..61e130d 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -72,6 +72,8 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) this->PopulateInterfaceProperty("INTERFACE_COMPILE_DEFINITIONS", te, cmGeneratorExpression::BuildInterface, properties, missingTargets); + this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", + te, properties); this->GenerateInterfaceProperties(te, os, properties); } diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index fc78eeb..4a7c6f9 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -127,6 +127,18 @@ void cmExportFileGenerator::GenerateImportConfig(std::ostream& os, //---------------------------------------------------------------------------- void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName, + cmTarget *target, + ImportPropertyMap &properties) +{ + const char *input = target->GetProperty(propName); + if (input) + { + properties[propName] = input; + } +} + +//---------------------------------------------------------------------------- +void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName, const char *outputName, cmTarget *target, cmGeneratorExpression::PreprocessContext preprocessRule, diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 8620dd1..eb3f3c3 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -101,6 +101,8 @@ protected: cmGeneratorExpression::PreprocessContext, ImportPropertyMap &properties, std::vector &missingTargets); + void PopulateInterfaceProperty(const char *propName, cmTarget *target, + ImportPropertyMap &properties); void GenerateInterfaceProperties(cmTarget *target, std::ostream& os, const ImportPropertyMap &properties); diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 7eed5ab..965f63d 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -89,6 +89,8 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) te, cmGeneratorExpression::InstallInterface, properties, missingTargets); + this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", + te, properties); this->GenerateInterfaceProperties(te, os, properties); } diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index e92dcd8..fd7a1a6 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -162,6 +162,10 @@ include(GenerateExportHeader) add_library(testSharedLibRequired SHARED testSharedLibRequired.cpp) generate_export_header(testSharedLibRequired) +set_property(TARGET testSharedLibRequired + PROPERTY + INTERFACE_POSITION_INDEPENDENT_CODE ON +) set_property(TARGET testSharedLibRequired APPEND PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}" ) diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index 72d11b6..4812e7e 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -167,6 +167,24 @@ target_link_libraries(deps_shared_iface testSharedLibDepends) target_include_directories(deps_shared_iface PRIVATE testSharedLibDepends) target_compile_definitions(deps_shared_iface PRIVATE testSharedLibDepends) +if (APPLE OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") + include(CheckCXXCompilerFlag) + check_cxx_compiler_flag(-fPIE run_pic_test) +else() + if (CMAKE_CXX_COMPILER_ID MATCHES "PGI" + OR CMAKE_CXX_COMPILER_ID MATCHES "PathScale" + OR CMAKE_SYSTEM_NAME MATCHES "IRIX64" + OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") + set(run_pic_test 0) + else() + set(run_pic_test 1) + endif() +endif() + +if (run_pic_test) + target_compile_definitions(deps_shared_iface PRIVATE CHECK_PIC_WORKS) +endif() + #----------------------------------------------------------------------------- # Test that targets imported from the build tree have their dependencies # evaluated correctly. The above already tests the same for the install tree. diff --git a/Tests/ExportImport/Import/A/deps_shared_iface.cpp b/Tests/ExportImport/Import/A/deps_shared_iface.cpp index 14aac0a..43f832a 100644 --- a/Tests/ExportImport/Import/A/deps_shared_iface.cpp +++ b/Tests/ExportImport/Import/A/deps_shared_iface.cpp @@ -2,6 +2,12 @@ #include "testSharedLibDepends.h" +#ifdef CHECK_PIC_WORKS +#if defined(__ELF__) && !defined(__PIC__) && !defined(__PIE__) +#error Expected by INTERFACE_POSITION_INDEPENDENT_CODE property of dependency +#endif +#endif + #ifdef TEST_SUBDIR_LIB #include "subdir.h" #endif -- cgit v0.12 From 1d74ba21f6ee70936191c94448c88fd10eb1e81c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 12 Jan 2013 12:13:44 +0100 Subject: Test evaluation target via export for generator expressions --- Tests/ExportImport/Export/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index fd7a1a6..dd615d1 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -186,7 +186,7 @@ set_property(TARGET testSharedLibDepends APPEND PROPERTY ) set_property(TARGET testSharedLibDepends APPEND PROPERTY LINK_INTERFACE_LIBRARIES - $<1:$> + $<$,EXECUTABLE>:$> ) # LINK_PRIVATE because the LINK_INTERFACE_LIBRARIES is specified above. -- cgit v0.12 From c2ab74acb9230d9218091d3fb5e87b6065f98e0b Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Wed, 16 Jan 2013 00:01:30 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 1e7fe50..e724067 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130115) +set(CMake_VERSION_TWEAK 20130116) #set(CMake_VERSION_RC 1) -- cgit v0.12 From c0f1af926feb3494ada1a311441ea144926157a2 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 16 Jan 2013 09:10:48 -0500 Subject: ExternalProject: Allow DEPENDS on normal targets (#13849) The ExternalProject_Add DEPENDS option adds two types of dependencies. It adds a target-level build order dependency between the external project target and the named targets. It also adds a file-level dependency on the "done" stamp file of the named external project targets. Targets not created by ExternalProject_Add have no such stamp file and no _EP_STAMP_DIR property. Prior to commit d14c0243 (Refactor repeated code into function, 2012-04-26) we unconditionally accepted an empty stamp dir and generated a dependency on a non-existent file. After that commit we generate an error that no stamp dir is set. Skip the file-level dependency when the named dependency is not an external project target in order to allow this use case. Teach the ExternalProject test to cover the case. --- Modules/ExternalProject.cmake | 7 +++++-- Tests/ExternalProject/CMakeLists.txt | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 2355dac..ed7fd7c 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -1558,8 +1558,11 @@ function(_ep_add_configure_command name) set(file_deps) get_property(deps TARGET ${name} PROPERTY _EP_DEPENDS) foreach(dep IN LISTS deps) - _ep_get_step_stampfile(${dep} "done" done_stamp_file) - list(APPEND file_deps ${done_stamp_file}) + get_property(is_ep TARGET ${dep} PROPERTY _EP_IS_EXTERNAL_PROJECT) + if(is_ep) + _ep_get_step_stampfile(${dep} "done" done_stamp_file) + list(APPEND file_deps ${done_stamp_file}) + endif() endforeach() get_property(cmd_set TARGET ${name} PROPERTY _EP_CONFIGURE_COMMAND SET) diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt index e24a979..602ff0f 100644 --- a/Tests/ExternalProject/CMakeLists.txt +++ b/Tests/ExternalProject/CMakeLists.txt @@ -50,6 +50,8 @@ if(NOT DEFINED can_build_tutorial_step5) endif() endif() +add_custom_target(NonExternalProjectTarget + COMMAND ${CMAKE_COMMAND} -E echo NonExternalProjectTarget) # Empty projects that test all the known ExternalProject_Add argument key words: # @@ -94,7 +96,7 @@ ExternalProject_Add(${proj} CVS_REPOSITORY "" CVS_MODULE "" CVS_TAG "" - DEPENDS "MinimalNoOpProject" + DEPENDS "MinimalNoOpProject" NonExternalProjectTarget DOWNLOAD_COMMAND "" INSTALL_COMMAND "" PATCH_COMMAND "" -- cgit v0.12 From bc65b74fa64bdd736eb67b6e579aa1db347f7790 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 16 Jan 2013 16:00:57 -0500 Subject: VS11: Fix VSExternalInclude test Set CMAKE_SUPPRESS_REGENERATION in the Lib1 and Lib2 projects so that their .vcxproj files do not contain references to ZERO_CHECK. Such references do not make sense when using the files in another .sln file. This does not reduce the effectiveness of the test because real projects that use include_external_msproject will have their own .vcxproj files not generated by CMake anyway. --- Tests/VSExternalInclude/Lib1/CMakeLists.txt | 1 + Tests/VSExternalInclude/Lib2/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/Tests/VSExternalInclude/Lib1/CMakeLists.txt b/Tests/VSExternalInclude/Lib1/CMakeLists.txt index 1cb01c5..9dfac86 100644 --- a/Tests/VSExternalInclude/Lib1/CMakeLists.txt +++ b/Tests/VSExternalInclude/Lib1/CMakeLists.txt @@ -1,3 +1,4 @@ +set(CMAKE_SUPPRESS_REGENERATION 1) project(LIB1) set(SOURCES lib1.cpp) diff --git a/Tests/VSExternalInclude/Lib2/CMakeLists.txt b/Tests/VSExternalInclude/Lib2/CMakeLists.txt index f726c3f..f451354 100644 --- a/Tests/VSExternalInclude/Lib2/CMakeLists.txt +++ b/Tests/VSExternalInclude/Lib2/CMakeLists.txt @@ -1,3 +1,4 @@ +set(CMAKE_SUPPRESS_REGENERATION 1) project(VSEXTERNAL_LIB2) include_directories(${VSEXTERNAL_LIB2_SOURCE_DIR}/../Lib1) -- cgit v0.12 From 24dcf0c0072d6e0ca5a1203a54b574d1db9e5a7d Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 16 Jan 2013 22:16:46 +0100 Subject: Make sure generator expressions can be used with target_include_directories. Handle the case that a generator expression is used before treating a non-target as an error. --- Source/cmTargetPropCommandBase.cxx | 12 ++++++++++++ .../CMakeCommands/target_include_directories/CMakeLists.txt | 7 ++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx index 69aaf17..7f15dcb 100644 --- a/Source/cmTargetPropCommandBase.cxx +++ b/Source/cmTargetPropCommandBase.cxx @@ -66,6 +66,14 @@ bool cmTargetPropCommandBase } //---------------------------------------------------------------------------- +static bool isGeneratorExpression(const std::string &lib) +{ + const std::string::size_type openpos = lib.find("$<"); + return (openpos != std::string::npos) + && (lib.find(">", openpos) != std::string::npos); +} + +//---------------------------------------------------------------------------- bool cmTargetPropCommandBase ::ProcessContentArgs(std::vector const& args, unsigned int &argIndex, bool prepend) @@ -105,6 +113,10 @@ bool cmTargetPropCommandBase content += sep + "$Property + ">"; } + else if(isGeneratorExpression(args[i])) + { + content += sep + args[i]; + } else if (!this->HandleNonTargetArg(content, sep, args[i], args[0])) { return false; diff --git a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt index a0f2ee0..8fa2eae 100644 --- a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt +++ b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt @@ -33,7 +33,12 @@ target_include_directories(target_include_directories PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/poison" ) target_include_directories(target_include_directories - BEFORE PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/cure" + BEFORE PUBLIC "$<$:${CMAKE_CURRENT_BINARY_DIR}/cure>" +) + +# Has no effect because the target is not defined: +target_include_directories(target_include_directories + BEFORE PUBLIC "$<$:${CMAKE_CURRENT_BINARY_DIR}/poison>" ) add_library(importedlib UNKNOWN IMPORTED) -- cgit v0.12 From 1800f702a056b2eb25eb35daf9ed8d6474ecd0f9 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 16 Jan 2013 17:54:30 +0100 Subject: Populate the link information cache before checking dependent properties. The dependent properties check can require the link information. --- Source/cmTarget.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 815da40..45862fb 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5422,14 +5422,14 @@ cmTarget::GetLinkInformation(const char* config, cmTarget *head) info = 0; } + // Store the information for this configuration. + cmTargetLinkInformationMap::value_type entry(key, info); + i = this->LinkInformation.insert(entry).first; + if (info) { this->CheckPropertyCompatibility(info, config); } - - // Store the information for this configuration. - cmTargetLinkInformationMap::value_type entry(key, info); - i = this->LinkInformation.insert(entry).first; } return i->second; } -- cgit v0.12 From 2b5459cd1a4f39ceeecd895583423ce737beb919 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Thu, 17 Jan 2013 00:01:19 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index e724067..d1d2160 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130116) +set(CMake_VERSION_TWEAK 20130117) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 6c8d8afe344aa2e0ba0c5c881d397a28a559dcbd Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 16 Jan 2013 16:42:39 +0100 Subject: Add the $ expression This new expression allows checking how a policy was set when a target was created. That information is only recorded for a subset of policies, so a whitelist is used. --- Source/cmDocumentGeneratorExpressions.h | 4 + Source/cmGeneratorExpressionEvaluator.cxx | 98 ++++++++++++++++++++++ Tests/RunCMake/CMP0004/CMP0004-NEW-result.txt | 1 + Tests/RunCMake/CMP0004/CMP0004-NEW-stderr.txt | 2 + Tests/RunCMake/CMP0004/CMP0004-NEW.cmake | 9 ++ Tests/RunCMake/CMP0004/CMP0004-OLD-result.txt | 1 + Tests/RunCMake/CMP0004/CMP0004-OLD-stderr.txt | 2 + Tests/RunCMake/CMP0004/CMP0004-OLD.cmake | 21 +++++ Tests/RunCMake/CMP0004/CMP0004-WARN-stderr.txt | 0 .../CMP0004/CMP0004-policy-genex-result.txt | 1 + .../CMP0004/CMP0004-policy-genex-stderr.txt | 2 + Tests/RunCMake/CMP0004/CMP0004-policy-genex.cmake | 14 ++++ Tests/RunCMake/CMP0004/CMakeLists.txt | 3 + Tests/RunCMake/CMP0004/RunCMakeTest.cmake | 5 ++ Tests/RunCMake/CMP0004/empty.cpp | 0 Tests/RunCMake/CMakeLists.txt | 1 + 16 files changed, 164 insertions(+) create mode 100644 Tests/RunCMake/CMP0004/CMP0004-NEW-result.txt create mode 100644 Tests/RunCMake/CMP0004/CMP0004-NEW-stderr.txt create mode 100644 Tests/RunCMake/CMP0004/CMP0004-NEW.cmake create mode 100644 Tests/RunCMake/CMP0004/CMP0004-OLD-result.txt create mode 100644 Tests/RunCMake/CMP0004/CMP0004-OLD-stderr.txt create mode 100644 Tests/RunCMake/CMP0004/CMP0004-OLD.cmake create mode 100644 Tests/RunCMake/CMP0004/CMP0004-WARN-stderr.txt create mode 100644 Tests/RunCMake/CMP0004/CMP0004-policy-genex-result.txt create mode 100644 Tests/RunCMake/CMP0004/CMP0004-policy-genex-stderr.txt create mode 100644 Tests/RunCMake/CMP0004/CMP0004-policy-genex.cmake create mode 100644 Tests/RunCMake/CMP0004/CMakeLists.txt create mode 100644 Tests/RunCMake/CMP0004/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/CMP0004/empty.cpp diff --git a/Source/cmDocumentGeneratorExpressions.h b/Source/cmDocumentGeneratorExpressions.h index fa21907..c2bf423 100644 --- a/Source/cmDocumentGeneratorExpressions.h +++ b/Source/cmDocumentGeneratorExpressions.h @@ -50,6 +50,10 @@ " $ = The value of the property prop\n" \ "on the target tgt. Note that tgt is not added as a dependency of\n" \ "the target this expression is evaluated on.\n" \ + " $ = '1' if the policy was NEW when " \ + "the 'head' target was created, else '0'. If the policy was not " \ + "set, the warning message for the policy will be emitted. This " \ + "generator expression only works for a subset of policies.\n" \ "Boolean expressions:\n" \ " $ = '1' if all '?' are '1', else '0'\n" \ " $ = '0' if all '?' are '0', else '1'\n" \ diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 8e40815a..2ddc058 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -488,6 +488,102 @@ static const struct TargetNameNode : public cmGeneratorExpressionNode } targetNameNode; //---------------------------------------------------------------------------- +static const char* targetPolicyWhitelist[] = { + "CMP0003" + , "CMP0004" + , "CMP0008" +}; + +cmPolicies::PolicyStatus statusForTarget(cmTarget *tgt, const char *policy) +{ +#define RETURN_POLICY(POLICY) \ + if (strcmp(policy, #POLICY) == 0) \ + { \ + return tgt->GetPolicyStatus ## POLICY (); \ + } \ + + RETURN_POLICY(CMP0003) + RETURN_POLICY(CMP0004) + RETURN_POLICY(CMP0008) + +#undef RETURN_POLICY + + assert("!Unreachable code. Not a valid policy"); + return cmPolicies::WARN; +} + +cmPolicies::PolicyID policyForString(const char *policy_id) +{ +#define RETURN_POLICY_ID(POLICY_ID) \ + if (strcmp(policy_id, #POLICY_ID) == 0) \ + { \ + return cmPolicies:: POLICY_ID; \ + } \ + + RETURN_POLICY_ID(CMP0003) + RETURN_POLICY_ID(CMP0004) + RETURN_POLICY_ID(CMP0008) + +#undef RETURN_POLICY_ID + + assert("!Unreachable code. Not a valid policy"); + return cmPolicies::CMP0002; +} + +//---------------------------------------------------------------------------- +static const struct TargetPolicyNode : public cmGeneratorExpressionNode +{ + TargetPolicyNode() {} + + virtual int NumExpectedParameters() const { return 1; } + + std::string Evaluate(const std::vector ¶meters, + cmGeneratorExpressionContext *context , + const GeneratorExpressionContent *content, + cmGeneratorExpressionDAGChecker *) const + { + if (!context->HeadTarget) + { + reportError(context, content->GetOriginalExpression(), + "$ may only be used with targets. It may not " + "be used with add_custom_command."); + return std::string(); + } + for (size_t i = 0; + i < (sizeof(targetPolicyWhitelist) / + sizeof(*targetPolicyWhitelist)); + ++i) + { + const char *policy = targetPolicyWhitelist[i]; + if (parameters.front() == policy) + { + cmMakefile *mf = context->HeadTarget->GetMakefile(); + switch(statusForTarget(context->HeadTarget, policy)) + { + case cmPolicies::WARN: + mf->IssueMessage(cmake::AUTHOR_WARNING, + mf->GetPolicies()-> + GetPolicyWarning(policyForString(policy))); + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::OLD: + return "0"; + case cmPolicies::NEW: + return "1"; + } + } + } + reportError(context, content->GetOriginalExpression(), + "$ may only be used with a limited number of " + "policies. Currently it may be used with policies CMP0003, CMP0004 " + "and CMP0008." + ); + return std::string(); + } + +} targetPolicyNode; + +//---------------------------------------------------------------------------- template struct TargetFilesystemArtifactResultCreator { @@ -714,6 +810,8 @@ cmGeneratorExpressionNode* GetNode(const std::string &identifier) return &targetPropertyNode; else if (identifier == "TARGET_NAME") return &targetNameNode; + else if (identifier == "TARGET_POLICY") + return &targetPolicyNode; else if (identifier == "BUILD_INTERFACE") return &buildInterfaceNode; else if (identifier == "INSTALL_INTERFACE") diff --git a/Tests/RunCMake/CMP0004/CMP0004-NEW-result.txt b/Tests/RunCMake/CMP0004/CMP0004-NEW-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMP0004/CMP0004-NEW-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0004/CMP0004-NEW-stderr.txt b/Tests/RunCMake/CMP0004/CMP0004-NEW-stderr.txt new file mode 100644 index 0000000..a21cb6a --- /dev/null +++ b/Tests/RunCMake/CMP0004/CMP0004-NEW-stderr.txt @@ -0,0 +1,2 @@ + Target "foo" links to item " bar " which has leading or trailing + whitespace. This is now an error according to policy CMP0004. diff --git a/Tests/RunCMake/CMP0004/CMP0004-NEW.cmake b/Tests/RunCMake/CMP0004/CMP0004-NEW.cmake new file mode 100644 index 0000000..7c61961 --- /dev/null +++ b/Tests/RunCMake/CMP0004/CMP0004-NEW.cmake @@ -0,0 +1,9 @@ + +cmake_minimum_required(VERSION 2.8) + +cmake_policy(SET CMP0004 NEW) + +add_library(foo SHARED empty.cpp) +add_library(bar SHARED empty.cpp) + +target_link_libraries(foo "$<1: bar >") diff --git a/Tests/RunCMake/CMP0004/CMP0004-OLD-result.txt b/Tests/RunCMake/CMP0004/CMP0004-OLD-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMP0004/CMP0004-OLD-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0004/CMP0004-OLD-stderr.txt b/Tests/RunCMake/CMP0004/CMP0004-OLD-stderr.txt new file mode 100644 index 0000000..782e45c --- /dev/null +++ b/Tests/RunCMake/CMP0004/CMP0004-OLD-stderr.txt @@ -0,0 +1,2 @@ + Target "bat" links to item " bar " which has leading or trailing + whitespace. This is now an error according to policy CMP0004. diff --git a/Tests/RunCMake/CMP0004/CMP0004-OLD.cmake b/Tests/RunCMake/CMP0004/CMP0004-OLD.cmake new file mode 100644 index 0000000..d6ed72c --- /dev/null +++ b/Tests/RunCMake/CMP0004/CMP0004-OLD.cmake @@ -0,0 +1,21 @@ + +cmake_minimum_required(VERSION 2.8) + +cmake_policy(SET CMP0004 OLD) + +add_library(foo SHARED empty.cpp) +add_library(bar SHARED empty.cpp) +add_library(bing SHARED empty.cpp) +add_library(bung SHARED empty.cpp) + +cmake_policy(SET CMP0004 NEW) + +add_library(bat SHARED empty.cpp) + +target_link_libraries(foo "$<1: bar >") +target_link_libraries(bing "$<$>: bar >") +target_link_libraries(bung "$<$: bar >") + +# The line below causes the error because the policy is NEW when bat +# is created. +target_link_libraries(bat "$<1: bar >") diff --git a/Tests/RunCMake/CMP0004/CMP0004-WARN-stderr.txt b/Tests/RunCMake/CMP0004/CMP0004-WARN-stderr.txt new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/CMP0004/CMP0004-policy-genex-result.txt b/Tests/RunCMake/CMP0004/CMP0004-policy-genex-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMP0004/CMP0004-policy-genex-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0004/CMP0004-policy-genex-stderr.txt b/Tests/RunCMake/CMP0004/CMP0004-policy-genex-stderr.txt new file mode 100644 index 0000000..eed53e7 --- /dev/null +++ b/Tests/RunCMake/CMP0004/CMP0004-policy-genex-stderr.txt @@ -0,0 +1,2 @@ + Target "foo" links to item " bat " which has leading or trailing + whitespace. This is now an error according to policy CMP0004. diff --git a/Tests/RunCMake/CMP0004/CMP0004-policy-genex.cmake b/Tests/RunCMake/CMP0004/CMP0004-policy-genex.cmake new file mode 100644 index 0000000..eab680a --- /dev/null +++ b/Tests/RunCMake/CMP0004/CMP0004-policy-genex.cmake @@ -0,0 +1,14 @@ + +cmake_minimum_required(VERSION 2.8) + +cmake_policy(SET CMP0004 NEW) + +add_library(foo SHARED empty.cpp) +add_library(bar SHARED empty.cpp) +add_library(bat SHARED empty.cpp) + +# The negation here avoids the error. +target_link_libraries(foo "$<$>: bar >") + +# The below line causes the error. +target_link_libraries(foo "$<$: bat >") diff --git a/Tests/RunCMake/CMP0004/CMakeLists.txt b/Tests/RunCMake/CMP0004/CMakeLists.txt new file mode 100644 index 0000000..e8db6b0 --- /dev/null +++ b/Tests/RunCMake/CMP0004/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMP0004/RunCMakeTest.cmake b/Tests/RunCMake/CMP0004/RunCMakeTest.cmake new file mode 100644 index 0000000..950d0ed --- /dev/null +++ b/Tests/RunCMake/CMP0004/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(CMP0004-OLD) +run_cmake(CMP0004-NEW) +run_cmake(CMP0004-policy-genex) diff --git a/Tests/RunCMake/CMP0004/empty.cpp b/Tests/RunCMake/CMP0004/empty.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 9b133b2..8822200 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -59,6 +59,7 @@ add_RunCMake_test(find_package) add_RunCMake_test(include) add_RunCMake_test(include_directories) add_RunCMake_test(list) +add_RunCMake_test(CMP0004) if("${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio [^6]") add_RunCMake_test(include_external_msproject) -- cgit v0.12 From c482dd8c976847ac89ed5e8752924a2c0ed386fa Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Fri, 18 Jan 2013 00:01:03 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index d1d2160..73e99df 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130117) +set(CMake_VERSION_TWEAK 20130118) #set(CMake_VERSION_RC 1) -- cgit v0.12 From d9afacced34b2ef17a6c3ca2f66975272cf8473f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 18 Jan 2013 16:10:20 +0100 Subject: Exit early if we find an inconsistent property. Further messages about inconsistency are distracting. --- Source/cmTarget.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 45862fb..7a2ead3 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4533,6 +4533,7 @@ bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, "INTERFACE_" << p << " property requirement\nof " "dependency \"" << li->Target->GetName() << "\".\n"; cmSystemTools::Error(e.str().c_str()); + break; } else { @@ -4559,6 +4560,7 @@ bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, "INTERFACE_" << p << " property on\ndependency \"" << li->Target->GetName() << "\" is in conflict.\n"; cmSystemTools::Error(e.str().c_str()); + break; } else { @@ -4586,6 +4588,7 @@ bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, "of " << p << " already determined\nfor \"" << this->GetName() << "\".\n"; cmSystemTools::Error(e.str().c_str()); + break; } else { -- cgit v0.12 From f447db7f102519e09258f0bd06668a9ae572ec68 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Fri, 18 Jan 2013 11:29:22 -0500 Subject: XCode generator won't infinitely parse compiler flags (bug #13354). When parsing the compiler flag list we reduce the search space on each iteration to be the subset of the string we hadn't searched before. --- Source/cmGlobalXCodeGenerator.cxx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 2cfe4da..0681ce5 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1367,16 +1367,18 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, } //---------------------------------------------------------------------------- -// This function removes each occurence of the flag and returns the last one +// This function removes each occurrence of the flag and returns the last one // (i.e., the dominant flag in GCC) std::string cmGlobalXCodeGenerator::ExtractFlag(const char* flag, std::string& flags) { std::string retFlag; - std::string::size_type pos = flags.rfind(flag); + std::string::size_type lastOccurancePos = flags.rfind(flag); bool saved = false; - while(pos != flags.npos) + while(lastOccurancePos != flags.npos) { + //increment pos, we use lastOccurancePos to reduce search space on next inc + std::string::size_type pos = lastOccurancePos; if(pos == 0 || flags[pos-1]==' ') { while(pos < flags.size() && flags[pos] != ' ') @@ -1388,9 +1390,12 @@ std::string cmGlobalXCodeGenerator::ExtractFlag(const char* flag, flags[pos] = ' '; pos++; } - } saved = true; - pos = flags.rfind(flag); + } + //decrement lastOccurancePos while making sure we don't loop around + //and become a very large positive number since size_type is unsigned + lastOccurancePos = lastOccurancePos == 0 ? 0 : lastOccurancePos-1; + lastOccurancePos = flags.rfind(flag,lastOccurancePos); } return retFlag; } -- cgit v0.12 From 5e572619c67c5ba38a68179111f7dea9648690ab Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sat, 19 Jan 2013 00:01:19 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 73e99df..487d456 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130118) +set(CMake_VERSION_TWEAK 20130119) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 35fbe4e4bc0f75d7034b60e28bac85e85e6569ed Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sun, 20 Jan 2013 00:01:25 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 487d456..3d9ab41 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130119) +set(CMake_VERSION_TWEAK 20130120) #set(CMake_VERSION_RC 1) -- cgit v0.12 From d7f15209385e17580d911bcc10f78c921bd8c3fd Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 20 Jan 2013 11:25:35 +0100 Subject: Don't wrap all targets in LINK_LIBRARIES in a TARGET_NAME genex. It is not necessary and the current state is unintentional. Before this patch, target_link_libraries(foo bar) causes the LINK_LIBRARIES property of foo to contain $ instead of just bar --- Source/cmTarget.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 815da40..077eeec 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2269,8 +2269,9 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, cmTarget *tgt = this->Makefile->FindTargetToUse(lib); const bool isNonImportedTarget = tgt && !tgt->IsImported(); - std::string libName = isNonImportedTarget ? targetNameGenex(lib) - : std::string(lib); + const std::string libName = (isNonImportedTarget && llt != GENERAL) + ? targetNameGenex(lib) + : std::string(lib); this->AppendProperty("LINK_LIBRARIES", this->GetDebugGeneratorExpressions(libName, llt).c_str()); -- cgit v0.12 From e98799105bdb296e8d9f5b3ef5cf99bcebcafc40 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 19 Jan 2013 11:21:14 +0100 Subject: Make INTERFACE determined properties readable in generator expressions. The properties are evaluated as link-dependent interface properties when evaluating the generator expressions. --- Source/cmGeneratorExpressionDAGChecker.cxx | 13 ++++++ Source/cmGeneratorExpressionDAGChecker.h | 3 ++ Source/cmGeneratorExpressionEvaluator.cxx | 21 ++++++++++ Source/cmTarget.cxx | 47 ++++++++++++++++++++++ Source/cmTarget.h | 2 + Tests/CMakeLists.txt | 1 + Tests/CompatibleInterface/CMakeLists.txt | 28 +++++++++++++ Tests/CompatibleInterface/empty.cpp | 1 + Tests/CompatibleInterface/main.cpp | 17 ++++++++ Tests/ExportImport/Import/A/CMakeLists.txt | 7 +++- Tests/ExportImport/Import/A/deps_shared_iface.cpp | 4 ++ Tests/RunCMake/CMakeLists.txt | 1 + Tests/RunCMake/CompatibleInterface/CMakeLists.txt | 3 ++ .../InterfaceBool-builtin-prop-result.txt | 1 + .../InterfaceBool-builtin-prop-stderr.txt | 5 +++ .../InterfaceBool-builtin-prop.cmake | 11 +++++ .../InterfaceBool-mismatch-depend-self-result.txt | 1 + .../InterfaceBool-mismatch-depend-self-stderr.txt | 3 ++ .../InterfaceBool-mismatch-depend-self.cmake | 11 +++++ .../InterfaceBool-mismatch-depends-result.txt | 1 + .../InterfaceBool-mismatch-depends-stderr.txt | 3 ++ .../InterfaceBool-mismatch-depends.cmake | 10 +++++ .../InterfaceBool-mismatched-use-result.txt | 1 + .../InterfaceBool-mismatched-use-stderr.txt | 4 ++ .../InterfaceBool-mismatched-use.cmake | 9 +++++ .../CompatibleInterface/RunCMakeTest.cmake | 6 +++ Tests/RunCMake/CompatibleInterface/main.cpp | 5 +++ 27 files changed, 218 insertions(+), 1 deletion(-) create mode 100644 Tests/CompatibleInterface/CMakeLists.txt create mode 100644 Tests/CompatibleInterface/empty.cpp create mode 100644 Tests/CompatibleInterface/main.cpp create mode 100644 Tests/RunCMake/CompatibleInterface/CMakeLists.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceBool-builtin-prop-result.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceBool-builtin-prop-stderr.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceBool-builtin-prop.cmake create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depend-self-result.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depend-self-stderr.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depend-self.cmake create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depends-result.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depends-stderr.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depends.cmake create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatched-use-result.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatched-use-stderr.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatched-use.cmake create mode 100644 Tests/RunCMake/CompatibleInterface/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/CompatibleInterface/main.cpp diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index 2e5b5ae..057f4c3 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -106,3 +106,16 @@ cmGeneratorExpressionDAGChecker::checkGraph() const } return DAG; } + +//---------------------------------------------------------------------------- +bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries() +{ + const cmGeneratorExpressionDAGChecker *top = this; + const cmGeneratorExpressionDAGChecker *parent = this->Parent; + while (parent) + { + parent = parent->Parent; + top = parent; + } + return top->Property == "LINK_LIBRARIES"; +} diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h index 48f26ed..3169291 100644 --- a/Source/cmGeneratorExpressionDAGChecker.h +++ b/Source/cmGeneratorExpressionDAGChecker.h @@ -35,6 +35,9 @@ struct cmGeneratorExpressionDAGChecker void reportError(cmGeneratorExpressionContext *context, const std::string &expr); + + bool EvaluatingLinkLibraries(); + private: Result checkGraph() const; diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 8e40815a..e842880 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -442,6 +442,27 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode const char *prop = target->GetProperty(propertyName.c_str()); if (!prop) { + if (target->IsImported()) + { + return std::string(); + } + if (dagCheckerParent && dagCheckerParent->EvaluatingLinkLibraries()) + { + return std::string(); + } + if (propertyName == "POSITION_INDEPENDENT_CODE") + { + return target->GetLinkInterfaceDependentBoolProperty( + "POSITION_INDEPENDENT_CODE", context->Config) ? "1" : "0"; + } + if (target->IsLinkInterfaceDependentBoolProperty(propertyName, + context->Config)) + { + return target->GetLinkInterfaceDependentBoolProperty( + propertyName, + context->Config) ? "1" : "0"; + } + return std::string(); } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 7a2ead3..c1c484b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4613,6 +4613,53 @@ bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, } //---------------------------------------------------------------------------- +bool isLinkDependentProperty(cmTarget *tgt, const std::string &p, + const char *interfaceProperty, + const char *config) +{ + cmComputeLinkInformation *info = tgt->GetLinkInformation(config); + + const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); + + for(cmComputeLinkInformation::ItemVector::const_iterator li = + deps.begin(); + li != deps.end(); ++li) + { + if (!li->Target) + { + continue; + } + const char *prop = li->Target->GetProperty(interfaceProperty); + if (!prop) + { + continue; + } + + std::vector props; + cmSystemTools::ExpandListArgument(prop, props); + + for(std::vector::iterator pi = props.begin(); + pi != props.end(); ++pi) + { + if (*pi == p) + { + return true; + } + } + } + + return false; +} + +//---------------------------------------------------------------------------- +bool cmTarget::IsLinkInterfaceDependentBoolProperty(const std::string &p, + const char *config) +{ + return isLinkDependentProperty(this, p, "COMPATIBLE_INTERFACE_BOOL", + config); +} + +//---------------------------------------------------------------------------- void cmTarget::GetLanguages(std::set& languages) const { for(std::vector::const_iterator diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 69a00c1..b3e17b2 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -495,6 +495,8 @@ public: void GetLinkDependentTargetsForProperty(const std::string &p, std::set &targets); bool IsNullImpliedByLinkLibraries(const std::string &p); + bool IsLinkInterfaceDependentBoolProperty(const std::string &p, + const char *config); void AddLinkDependentTargetsForProperties( const std::map &map); diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 2f7df01..0c75892 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -216,6 +216,7 @@ if(BUILD_TESTING) ADD_TEST_MACRO(PolicyScope PolicyScope) ADD_TEST_MACRO(EmptyLibrary EmptyLibrary) ADD_TEST_MACRO(CompileDefinitions CompileDefinitions) + ADD_TEST_MACRO(CompatibleInterface CompatibleInterface) set_tests_properties(EmptyLibrary PROPERTIES PASS_REGULAR_EXPRESSION "CMake Error: CMake can not determine linker language for target:test") ADD_TEST_MACRO(CrossCompile CrossCompile) diff --git a/Tests/CompatibleInterface/CMakeLists.txt b/Tests/CompatibleInterface/CMakeLists.txt new file mode 100644 index 0000000..d0eb60f --- /dev/null +++ b/Tests/CompatibleInterface/CMakeLists.txt @@ -0,0 +1,28 @@ + +cmake_minimum_required(VERSION 2.8) + +project(CompatibleInterface) + +add_library(iface1 empty.cpp) +set_property(TARGET iface1 APPEND PROPERTY + COMPATIBLE_INTERFACE_BOOL + BOOL_PROP1 + BOOL_PROP2 + BOOL_PROP3 +) + +set_property(TARGET iface1 PROPERTY INTERFACE_BOOL_PROP1 ON) +set_property(TARGET iface1 PROPERTY INTERFACE_BOOL_PROP2 ON) + +add_executable(CompatibleInterface main.cpp) +target_link_libraries(CompatibleInterface iface1) + +set_property(TARGET CompatibleInterface PROPERTY BOOL_PROP2 ON) +set_property(TARGET CompatibleInterface PROPERTY BOOL_PROP3 ON) + +target_compile_definitions(CompatibleInterface + PRIVATE + $<$>:BOOL_PROP1> + $<$>:BOOL_PROP2> + $<$>:BOOL_PROP3> +) diff --git a/Tests/CompatibleInterface/empty.cpp b/Tests/CompatibleInterface/empty.cpp new file mode 100644 index 0000000..0032329 --- /dev/null +++ b/Tests/CompatibleInterface/empty.cpp @@ -0,0 +1 @@ +// no content diff --git a/Tests/CompatibleInterface/main.cpp b/Tests/CompatibleInterface/main.cpp new file mode 100644 index 0000000..b7c6638 --- /dev/null +++ b/Tests/CompatibleInterface/main.cpp @@ -0,0 +1,17 @@ + +#ifndef BOOL_PROP1 +#error Expected BOOL_PROP1 +#endif + +#ifndef BOOL_PROP2 +#error Expected BOOL_PROP2 +#endif + +#ifndef BOOL_PROP3 +#error Expected BOOL_PROP3 +#endif + +int main(int argc, char **argv) +{ + return 0; +} diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index 4812e7e..83331cf 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -165,7 +165,11 @@ target_compile_definitions(deps_iface PRIVATE testLibDepends) add_executable(deps_shared_iface deps_shared_iface.cpp) target_link_libraries(deps_shared_iface testSharedLibDepends) target_include_directories(deps_shared_iface PRIVATE testSharedLibDepends) -target_compile_definitions(deps_shared_iface PRIVATE testSharedLibDepends) +target_compile_definitions(deps_shared_iface + PRIVATE + testSharedLibDepends + $<$>:PIC_PROPERTY_IS_ON> +) if (APPLE OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") include(CheckCXXCompilerFlag) @@ -194,4 +198,5 @@ target_link_libraries(deps_shared_iface2 bld_testSharedLibDepends bld_subdirlib) target_include_directories(deps_shared_iface2 PRIVATE bld_testSharedLibDepends bld_subdirlib) target_compile_definitions(deps_shared_iface2 PRIVATE bld_testSharedLibDepends TEST_SUBDIR_LIB + $<$>:PIC_PROPERTY_IS_ON> ) diff --git a/Tests/ExportImport/Import/A/deps_shared_iface.cpp b/Tests/ExportImport/Import/A/deps_shared_iface.cpp index 43f832a..8ed032e 100644 --- a/Tests/ExportImport/Import/A/deps_shared_iface.cpp +++ b/Tests/ExportImport/Import/A/deps_shared_iface.cpp @@ -8,6 +8,10 @@ #endif #endif +#ifndef PIC_PROPERTY_IS_ON +#error Expected PIC_PROPERTY_IS_ON +#endif + #ifdef TEST_SUBDIR_LIB #include "subdir.h" #endif diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 9b133b2..fc1960f 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -53,6 +53,7 @@ add_RunCMake_test(ObjectLibrary) if(NOT WIN32) add_RunCMake_test(PositionIndependentCode) endif() +add_RunCMake_test(CompatibleInterface) add_RunCMake_test(build_command) add_RunCMake_test(find_package) diff --git a/Tests/RunCMake/CompatibleInterface/CMakeLists.txt b/Tests/RunCMake/CompatibleInterface/CMakeLists.txt new file mode 100644 index 0000000..68dd8d6 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(${RunCMake_TEST} CXX) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceBool-builtin-prop-result.txt b/Tests/RunCMake/CompatibleInterface/InterfaceBool-builtin-prop-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceBool-builtin-prop-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceBool-builtin-prop-stderr.txt b/Tests/RunCMake/CompatibleInterface/InterfaceBool-builtin-prop-stderr.txt new file mode 100644 index 0000000..1a925b6 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceBool-builtin-prop-stderr.txt @@ -0,0 +1,5 @@ +CMake Error in CMakeLists.txt: + Target "foo" has property "INCLUDE_DIRECTORIES" listed in its + COMPATIBLE_INTERFACE_BOOL property. This is not allowed. Only + user-defined properties may appear listed in the COMPATIBLE_INTERFACE_BOOL + property. diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceBool-builtin-prop.cmake b/Tests/RunCMake/CompatibleInterface/InterfaceBool-builtin-prop.cmake new file mode 100644 index 0000000..5feb4d5 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceBool-builtin-prop.cmake @@ -0,0 +1,11 @@ + +add_library(foo UNKNOWN IMPORTED) +add_library(bar UNKNOWN IMPORTED) + +set_property(TARGET foo APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL INCLUDE_DIRECTORIES) +set_property(TARGET foo PROPERTY INTERFACE_INCLUDE_DIRECTORIES ON) +set_property(TARGET bar PROPERTY INTERFACE_INCLUDE_DIRECTORIES ON) + +add_executable(user main.cpp) +set_property(TARGET user PROPERTY INCLUDE_DIRECTORIES OFF) +target_link_libraries(user foo bar) diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depend-self-result.txt b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depend-self-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depend-self-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depend-self-stderr.txt b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depend-self-stderr.txt new file mode 100644 index 0000000..0476da9 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depend-self-stderr.txt @@ -0,0 +1,3 @@ +CMake Error: Property SOMEPROP on target "user" does +not match the INTERFACE_SOMEPROP property requirement +of dependency "foo". diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depend-self.cmake b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depend-self.cmake new file mode 100644 index 0000000..90543e8 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depend-self.cmake @@ -0,0 +1,11 @@ + +add_library(foo UNKNOWN IMPORTED) +add_library(bar UNKNOWN IMPORTED) + +set_property(TARGET foo APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL SOMEPROP) +set_property(TARGET foo PROPERTY INTERFACE_SOMEPROP ON) +set_property(TARGET bar PROPERTY INTERFACE_SOMEPROP ON) + +add_executable(user main.cpp) +set_property(TARGET user PROPERTY SOMEPROP OFF) +target_link_libraries(user foo bar) diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depends-result.txt b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depends-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depends-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depends-stderr.txt b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depends-stderr.txt new file mode 100644 index 0000000..d885c09 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depends-stderr.txt @@ -0,0 +1,3 @@ +CMake Error: The INTERFACE_SOMEPROP property of "bar" does +not agree with the value of SOMEPROP already determined +for "user". diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depends.cmake b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depends.cmake new file mode 100644 index 0000000..69be796 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatch-depends.cmake @@ -0,0 +1,10 @@ + +add_library(foo UNKNOWN IMPORTED) +add_library(bar UNKNOWN IMPORTED) + +set_property(TARGET foo APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL SOMEPROP) +set_property(TARGET foo PROPERTY INTERFACE_SOMEPROP ON) +set_property(TARGET bar PROPERTY INTERFACE_SOMEPROP OFF) + +add_executable(user main.cpp) +target_link_libraries(user foo bar) diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatched-use-result.txt b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatched-use-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatched-use-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatched-use-stderr.txt b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatched-use-stderr.txt new file mode 100644 index 0000000..8556ee0 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatched-use-stderr.txt @@ -0,0 +1,4 @@ +CMake Error: Property SOMEPROP on target "user" is +implied to be FALSE because it was used to determine the link libraries +already. The INTERFACE_SOMEPROP property on +dependency "foo" is in conflict. diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatched-use.cmake b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatched-use.cmake new file mode 100644 index 0000000..ccfad0a --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceBool-mismatched-use.cmake @@ -0,0 +1,9 @@ + +add_library(foo UNKNOWN IMPORTED) +add_library(bar UNKNOWN IMPORTED) + +set_property(TARGET foo APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL SOMEPROP) +set_property(TARGET foo PROPERTY INTERFACE_SOMEPROP ON) + +add_executable(user main.cpp) +target_link_libraries(user foo $<$,prop>:bar>) diff --git a/Tests/RunCMake/CompatibleInterface/RunCMakeTest.cmake b/Tests/RunCMake/CompatibleInterface/RunCMakeTest.cmake new file mode 100644 index 0000000..ba8917b --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/RunCMakeTest.cmake @@ -0,0 +1,6 @@ +include(RunCMake) + +run_cmake(InterfaceBool-mismatch-depends) +run_cmake(InterfaceBool-mismatch-depend-self) +run_cmake(InterfaceBool-mismatched-use) +run_cmake(InterfaceBool-builtin-prop) diff --git a/Tests/RunCMake/CompatibleInterface/main.cpp b/Tests/RunCMake/CompatibleInterface/main.cpp new file mode 100644 index 0000000..65eddcf --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/main.cpp @@ -0,0 +1,5 @@ + +int main(int argc, char **argv) +{ + return 0; +} -- cgit v0.12 From 02d4e53f48574820423ec5f0a99e96da2b9fe857 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 20 Jan 2013 18:02:13 +0100 Subject: Generate new-style cmake code during export. Use empty end*() commands and lowercase commands. --- Source/cmExportFileGenerator.cxx | 122 ++++++++++++++++---------------- Source/cmExportInstallFileGenerator.cxx | 22 +++--- 2 files changed, 72 insertions(+), 72 deletions(-) diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 4a7c6f9..88c4876 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -81,16 +81,16 @@ bool cmExportFileGenerator::GenerateImportFile() // Protect that file against use with older CMake versions. os << "# Generated by CMake " << cmVersion::GetCMakeVersion() << "\n\n"; - os << "IF(\"${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}\" LESS 2.5)\n" - << " MESSAGE(FATAL_ERROR \"CMake >= 2.6.0 required\")\n" - << "ENDIF(\"${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}\" LESS 2.5)\n"; + os << "if(\"${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}\" LESS 2.5)\n" + << " message(FATAL_ERROR \"CMake >= 2.6.0 required\")\n" + << "endif()\n"; // Isolate the file policy level. // We use 2.6 here instead of the current version because newer // versions of CMake should be able to export files imported by 2.6 // until the import format changes. - os << "CMAKE_POLICY(PUSH)\n" - << "CMAKE_POLICY(VERSION 2.6)\n"; + os << "cmake_policy(PUSH)\n" + << "cmake_policy(VERSION 2.6)\n"; // Start with the import file header. this->GenerateImportHeaderCode(os); @@ -100,7 +100,7 @@ bool cmExportFileGenerator::GenerateImportFile() // End with the import file footer. this->GenerateImportFooterCode(os); - os << "CMAKE_POLICY(POP)\n"; + os << "cmake_policy(POP)\n"; return result; } @@ -186,7 +186,7 @@ void cmExportFileGenerator::GenerateInterfaceProperties(cmTarget *target, { std::string targetName = this->Namespace; targetName += target->GetName(); - os << "SET_TARGET_PROPERTIES(" << targetName << " PROPERTIES\n"; + os << "set_target_properties(" << targetName << " PROPERTIES\n"; for(ImportPropertyMap::const_iterator pi = properties.begin(); pi != properties.end(); ++pi) { @@ -536,7 +536,7 @@ void cmExportFileGenerator::GenerateImportHeaderCode(std::ostream& os, void cmExportFileGenerator::GenerateImportFooterCode(std::ostream& os) { os << "# Commands beyond this point should not need to know the version.\n" - << "SET(CMAKE_IMPORT_FILE_VERSION)\n"; + << "set(CMAKE_IMPORT_FILE_VERSION)\n"; } //---------------------------------------------------------------------------- @@ -545,7 +545,7 @@ void cmExportFileGenerator::GenerateImportVersionCode(std::ostream& os) // Store an import file format version. This will let us change the // format later while still allowing old import files to work. os << "# Commands may need to know the format version.\n" - << "SET(CMAKE_IMPORT_FILE_VERSION 1)\n" + << "set(CMAKE_IMPORT_FILE_VERSION 1)\n" << "\n"; } @@ -553,31 +553,31 @@ void cmExportFileGenerator::GenerateImportVersionCode(std::ostream& os) void cmExportFileGenerator::GenerateExpectedTargetsCode(std::ostream& os, const std::string &expectedTargets) { - os << "SET(_targetsDefined)\n" - "SET(_targetsNotDefined)\n" - "SET(_expectedTargets)\n" - "FOREACH(_expectedTarget " << expectedTargets << ")\n" - " LIST(APPEND _expectedTargets ${_expectedTarget})\n" - " IF(NOT TARGET ${_expectedTarget})\n" - " LIST(APPEND _targetsNotDefined ${_expectedTarget})\n" - " ENDIF(NOT TARGET ${_expectedTarget})\n" - " IF(TARGET ${_expectedTarget})\n" - " LIST(APPEND _targetsDefined ${_expectedTarget})\n" - " ENDIF(TARGET ${_expectedTarget})\n" - "ENDFOREACH(_expectedTarget)\n" - "IF(\"${_targetsDefined}\" STREQUAL \"${_expectedTargets}\")\n" - " SET(CMAKE_IMPORT_FILE_VERSION)\n" - " CMAKE_POLICY(POP)\n" - " RETURN()\n" - "ENDIF(\"${_targetsDefined}\" STREQUAL \"${_expectedTargets}\")\n" - "IF(NOT \"${_targetsDefined}\" STREQUAL \"\")\n" - " MESSAGE(FATAL_ERROR \"Some (but not all) targets in this export " + os << "set(_targetsDefined)\n" + "set(_targetsNotDefined)\n" + "set(_expectedTargets)\n" + "foreach(_expectedTarget " << expectedTargets << ")\n" + " list(APPEND _expectedTargets ${_expectedTarget})\n" + " if(NOT TARGET ${_expectedTarget})\n" + " list(APPEND _targetsNotDefined ${_expectedTarget})\n" + " endif()\n" + " if(TARGET ${_expectedTarget})\n" + " list(APPEND _targetsDefined ${_expectedTarget})\n" + " endif()\n" + "endforeach()\n" + "if(\"${_targetsDefined}\" STREQUAL \"${_expectedTargets}\")\n" + " set(CMAKE_IMPORT_FILE_VERSION)\n" + " cmake_policy(POP)\n" + " return()\n" + "endif()\n" + "if(NOT \"${_targetsDefined}\" STREQUAL \"\")\n" + " message(FATAL_ERROR \"Some (but not all) targets in this export " "set were already defined.\\nTargets Defined: ${_targetsDefined}\\n" "Targets not yet defined: ${_targetsNotDefined}\\n\")\n" - "ENDIF(NOT \"${_targetsDefined}\" STREQUAL \"\")\n" - "UNSET(_targetsDefined)\n" - "UNSET(_targetsNotDefined)\n" - "UNSET(_expectedTargets)\n" + "endif()\n" + "unset(_targetsDefined)\n" + "unset(_targetsNotDefined)\n" + "unset(_expectedTargets)\n" "\n\n"; } //---------------------------------------------------------------------------- @@ -594,16 +594,16 @@ cmExportFileGenerator switch(target->GetType()) { case cmTarget::EXECUTABLE: - os << "ADD_EXECUTABLE(" << targetName << " IMPORTED)\n"; + os << "add_executable(" << targetName << " IMPORTED)\n"; break; case cmTarget::STATIC_LIBRARY: - os << "ADD_LIBRARY(" << targetName << " STATIC IMPORTED)\n"; + os << "add_library(" << targetName << " STATIC IMPORTED)\n"; break; case cmTarget::SHARED_LIBRARY: - os << "ADD_LIBRARY(" << targetName << " SHARED IMPORTED)\n"; + os << "add_library(" << targetName << " SHARED IMPORTED)\n"; break; case cmTarget::MODULE_LIBRARY: - os << "ADD_LIBRARY(" << targetName << " MODULE IMPORTED)\n"; + os << "add_library(" << targetName << " MODULE IMPORTED)\n"; break; default: // should never happen break; @@ -612,27 +612,27 @@ cmExportFileGenerator // Mark the imported executable if it has exports. if(target->IsExecutableWithExports()) { - os << "SET_PROPERTY(TARGET " << targetName + os << "set_property(TARGET " << targetName << " PROPERTY ENABLE_EXPORTS 1)\n"; } // Mark the imported library if it is a framework. if(target->IsFrameworkOnApple()) { - os << "SET_PROPERTY(TARGET " << targetName + os << "set_property(TARGET " << targetName << " PROPERTY FRAMEWORK 1)\n"; } // Mark the imported executable if it is an application bundle. if(target->IsAppBundleOnApple()) { - os << "SET_PROPERTY(TARGET " << targetName + os << "set_property(TARGET " << targetName << " PROPERTY MACOSX_BUNDLE 1)\n"; } if (target->IsCFBundleOnApple()) { - os << "SET_PROPERTY(TARGET " << targetName + os << "set_property(TARGET " << targetName << " PROPERTY BUNDLE 1)\n"; } os << "\n"; @@ -652,7 +652,7 @@ cmExportFileGenerator // Set the import properties. os << "# Import target \"" << targetName << "\" for configuration \"" << config << "\"\n"; - os << "SET_PROPERTY(TARGET " << targetName + os << "set_property(TARGET " << targetName << " APPEND PROPERTY IMPORTED_CONFIGURATIONS "; if(config && *config) { @@ -663,7 +663,7 @@ cmExportFileGenerator os << "NOCONFIG"; } os << ")\n"; - os << "SET_TARGET_PROPERTIES(" << targetName << " PROPERTIES\n"; + os << "set_target_properties(" << targetName << " PROPERTIES\n"; for(ImportPropertyMap::const_iterator pi = properties.begin(); pi != properties.end(); ++pi) { @@ -689,17 +689,17 @@ void cmExportFileGenerator::GenerateMissingTargetsCheckCode(std::ostream& os, { if (emitted.insert(missingTargets[i]).second) { - os << "IF(NOT TARGET \"" << missingTargets[i] << "\" )\n" - << " IF(CMAKE_FIND_PACKAGE_NAME)\n" - << " SET( ${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)\n" - << " SET( ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE " + os << "if(NOT TARGET \"" << missingTargets[i] << "\" )\n" + << " if(CMAKE_FIND_PACKAGE_NAME)\n" + << " set( ${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)\n" + << " set( ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE " << "\"Required imported target \\\"" << missingTargets[i] << "\\\" not found ! \")\n" - << " ELSE()\n" - << " MESSAGE(FATAL_ERROR \"Required imported target \\\"" + << " else()\n" + << " message(FATAL_ERROR \"Required imported target \\\"" << missingTargets[i] << "\\\" not found ! \")\n" - << " ENDIF()\n" - << "ENDIF()\n"; + << " endif()\n" + << "endif()\n"; } } os << "\n"; @@ -718,10 +718,10 @@ cmExportFileGenerator::GenerateImportedFileCheckLoop(std::ostream& os) // on SUSE with a mysql pkg-config file, which claimed everything is fine, // but the development package was not installed.). os << "# Loop over all imported files and verify that they actually exist\n" - "FOREACH(target ${_IMPORT_CHECK_TARGETS} )\n" - " FOREACH(file ${_IMPORT_CHECK_FILES_FOR_${target}} )\n" - " IF(NOT EXISTS \"${file}\" )\n" - " MESSAGE(FATAL_ERROR \"The imported target \\\"${target}\\\"" + "foreach(target ${_IMPORT_CHECK_TARGETS} )\n" + " foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )\n" + " if(NOT EXISTS \"${file}\" )\n" + " message(FATAL_ERROR \"The imported target \\\"${target}\\\"" " references the file\n" " \\\"${file}\\\"\n" "but this file does not exist. Possible reasons include:\n" @@ -731,11 +731,11 @@ cmExportFileGenerator::GenerateImportedFileCheckLoop(std::ostream& os) " \\\"${CMAKE_CURRENT_LIST_FILE}\\\"\n" "but not all the files it references.\n" "\")\n" - " ENDIF()\n" - " ENDFOREACH()\n" - " UNSET(_IMPORT_CHECK_FILES_FOR_${target})\n" - "ENDFOREACH()\n" - "UNSET(_IMPORT_CHECK_TARGETS)\n" + " endif()\n" + " endforeach()\n" + " unset(_IMPORT_CHECK_FILES_FOR_${target})\n" + "endforeach()\n" + "unset(_IMPORT_CHECK_TARGETS)\n" "\n"; } @@ -751,8 +751,8 @@ cmExportFileGenerator std::string targetName = this->Namespace; targetName += target->GetName(); - os << "LIST(APPEND _IMPORT_CHECK_TARGETS " << targetName << " )\n" - "LIST(APPEND _IMPORT_CHECK_FILES_FOR_" << targetName << " "; + os << "list(APPEND _IMPORT_CHECK_TARGETS " << targetName << " )\n" + "list(APPEND _IMPORT_CHECK_FILES_FOR_" << targetName << " "; for(std::set::const_iterator li = importedLocations.begin(); li != importedLocations.end(); diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 965f63d..c5ddfad 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -57,7 +57,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) else { cmOStringStream e; - e << "INSTALL(EXPORT \"" + e << "install(EXPORT \"" << this->IEGen->GetExportSet()->GetName() << "\" ...) " << "includes target \"" << te->Target->GetName() << "\" more than once in the export set."; @@ -98,12 +98,12 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) // Now load per-configuration properties for them. os << "# Load information for each installed configuration.\n" - << "GET_FILENAME_COMPONENT(_DIR \"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n" - << "FILE(GLOB CONFIG_FILES \"${_DIR}/" + << "get_filename_component(_DIR \"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n" + << "file(GLOB CONFIG_FILES \"${_DIR}/" << this->GetConfigImportFileGlob() << "\")\n" - << "FOREACH(f ${CONFIG_FILES})\n" - << " INCLUDE(${f})\n" - << "ENDFOREACH(f)\n" + << "foreach(f ${CONFIG_FILES})\n" + << " include(${f})\n" + << "endforeach()\n" << "\n"; this->GenerateImportedFileCheckLoop(os); @@ -193,12 +193,12 @@ cmExportInstallFileGenerator { std::string dest = installDest; os << "# Compute the installation prefix relative to this file.\n" - << "GET_FILENAME_COMPONENT(_IMPORT_PREFIX " + << "get_filename_component(_IMPORT_PREFIX " << "\"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n"; while(!dest.empty()) { os << - "GET_FILENAME_COMPONENT(_IMPORT_PREFIX \"${_IMPORT_PREFIX}\" PATH)\n"; + "get_filename_component(_IMPORT_PREFIX \"${_IMPORT_PREFIX}\" PATH)\n"; dest = cmSystemTools::GetFilenamePath(dest); } os << "\n"; @@ -257,7 +257,7 @@ cmExportInstallFileGenerator if(!this->ImportPrefix.empty()) { os << "# Cleanup temporary variables.\n" - << "SET(_IMPORT_PREFIX)\n" + << "set(_IMPORT_PREFIX)\n" << "\n"; } } @@ -427,7 +427,7 @@ cmExportInstallFileGenerator { const char* installDest = this->IEGen->GetDestination(); cmOStringStream e; - e << "INSTALL(EXPORT \"" + e << "install(EXPORT \"" << this->IEGen->GetExportSet()->GetName() << "\") given absolute " << "DESTINATION \"" << installDest << "\" but the export " @@ -445,7 +445,7 @@ cmExportInstallFileGenerator int occurrences) { cmOStringStream e; - e << "INSTALL(EXPORT \"" + e << "install(EXPORT \"" << this->IEGen->GetExportSet()->GetName() << "\" ...) " << "includes target \"" << depender->GetName() -- cgit v0.12 From 3ded614e31e9dcc4afa3ee9885dadf830a05dd21 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Mon, 21 Jan 2013 00:01:20 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 3d9ab41..45fc936 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130120) +set(CMake_VERSION_TWEAK 20130121) #set(CMake_VERSION_RC 1) -- cgit v0.12 From bd82bb4787410a0bdd6120b8c449f5d31ecc4c28 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 20 Jan 2013 17:18:23 +0100 Subject: Clear the link information in ClearLinkMaps. The cache here needs to be cleared if GetLinkInformation is called at configure-time, such as during an export(). The next commit does exactly that, and without this patch, the LinkLanguage test would fail. --- Source/cmTarget.cxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c1c484b..2600db5 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1520,6 +1520,13 @@ void cmTarget::ClearLinkMaps() this->Internal->LinkImplMap.clear(); this->Internal->LinkInterfaceMap.clear(); this->Internal->LinkClosureMap.clear(); + for (cmTargetLinkInformationMap::const_iterator it + = this->LinkInformation.begin(); + it != this->LinkInformation.end(); ++it) + { + delete it->second; + } + this->LinkInformation.clear(); } //---------------------------------------------------------------------------- -- cgit v0.12 From 830246e841d24cc9513c857859a4327ffb1d3da5 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 20 Jan 2013 17:09:29 +0100 Subject: Export the COMPATIBLE_INTERFACE_BOOL content properties --- Source/cmExportBuildFileGenerator.cxx | 1 + Source/cmExportFileGenerator.cxx | 74 +++++++++++++++++++++++ Source/cmExportFileGenerator.h | 2 + Source/cmExportInstallFileGenerator.cxx | 1 + Tests/ExportImport/Export/CMakeLists.txt | 9 +++ Tests/ExportImport/Import/A/CMakeLists.txt | 2 + Tests/ExportImport/Import/A/deps_shared_iface.cpp | 4 ++ 7 files changed, 93 insertions(+) diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 61e130d..7147f86 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -74,6 +74,7 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) properties, missingTargets); this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", te, properties); + this->PopulateCompatibleInterfaceProperties(te, properties); this->GenerateInterfaceProperties(te, os, properties); } diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 4a7c6f9..3a6294a 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -21,6 +21,7 @@ #include "cmTarget.h" #include "cmTargetExport.h" #include "cmVersion.h" +#include "cmComputeLinkInformation.h" #include @@ -177,6 +178,79 @@ void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName, properties, missingTargets); } + +//---------------------------------------------------------------------------- +void getPropertyContents(cmTarget *tgt, const char *prop, + std::set &ifaceProperties) +{ + const char *p = tgt->GetProperty(prop); + if (!p) + { + return; + } + std::vector content; + cmSystemTools::ExpandListArgument(p, content); + for (std::vector::const_iterator ci = content.begin(); + ci != content.end(); ++ci) + { + ifaceProperties.insert(*ci); + } +} + +//---------------------------------------------------------------------------- +void getCompatibleInterfaceProperties(cmTarget *target, + std::set &ifaceProperties, + const char *config) +{ + cmComputeLinkInformation *info = target->GetLinkInformation(config); + + const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); + + for(cmComputeLinkInformation::ItemVector::const_iterator li = + deps.begin(); + li != deps.end(); ++li) + { + if (!li->Target) + { + continue; + } + getPropertyContents(li->Target, + "COMPATIBLE_INTERFACE_BOOL", + ifaceProperties); + } +} + +//---------------------------------------------------------------------------- +void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( + cmTarget *target, + ImportPropertyMap &properties) +{ + this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_BOOL", + target, properties); + + std::set ifaceProperties; + + getPropertyContents(target, "COMPATIBLE_INTERFACE_BOOL", ifaceProperties); + + getCompatibleInterfaceProperties(target, ifaceProperties, 0); + + std::vector configNames; + target->GetMakefile()->GetConfigurations(configNames); + + for (std::vector::const_iterator ci = configNames.begin(); + ci != configNames.end(); ++ci) + { + getCompatibleInterfaceProperties(target, ifaceProperties, ci->c_str()); + } + + for (std::set::const_iterator it = ifaceProperties.begin(); + it != ifaceProperties.end(); ++it) + { + this->PopulateInterfaceProperty(("INTERFACE_" + *it).c_str(), + target, properties); + } +} + //---------------------------------------------------------------------------- void cmExportFileGenerator::GenerateInterfaceProperties(cmTarget *target, std::ostream& os, diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index eb3f3c3..b39df0f 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -103,6 +103,8 @@ protected: std::vector &missingTargets); void PopulateInterfaceProperty(const char *propName, cmTarget *target, ImportPropertyMap &properties); + void PopulateCompatibleInterfaceProperties(cmTarget *target, + ImportPropertyMap &properties); void GenerateInterfaceProperties(cmTarget *target, std::ostream& os, const ImportPropertyMap &properties); diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 965f63d..526a6be 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -91,6 +91,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) properties, missingTargets); this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", te, properties); + this->PopulateCompatibleInterfaceProperties(te, properties); this->GenerateInterfaceProperties(te, os, properties); } diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index dd615d1..5992293 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -173,6 +173,15 @@ set_property(TARGET testSharedLibRequired APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}" ) +set_property(TARGET testSharedLibRequired + APPEND PROPERTY + COMPATIBLE_INTERFACE_BOOL CUSTOM_PROP +) +set_property(TARGET testSharedLibRequired + PROPERTY + INTERFACE_CUSTOM_PROP ON +) + add_library(testSharedLibDepends SHARED testSharedLibDepends.cpp) set_property(TARGET testSharedLibDepends APPEND PROPERTY diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index 83331cf..4df5771 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -169,6 +169,7 @@ target_compile_definitions(deps_shared_iface PRIVATE testSharedLibDepends $<$>:PIC_PROPERTY_IS_ON> + $<$>:CUSTOM_PROPERTY_IS_ON> ) if (APPLE OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") @@ -199,4 +200,5 @@ target_include_directories(deps_shared_iface2 PRIVATE bld_testSharedLibDepends b target_compile_definitions(deps_shared_iface2 PRIVATE bld_testSharedLibDepends TEST_SUBDIR_LIB $<$>:PIC_PROPERTY_IS_ON> + $<$>:CUSTOM_PROPERTY_IS_ON> ) diff --git a/Tests/ExportImport/Import/A/deps_shared_iface.cpp b/Tests/ExportImport/Import/A/deps_shared_iface.cpp index 8ed032e..a33f200 100644 --- a/Tests/ExportImport/Import/A/deps_shared_iface.cpp +++ b/Tests/ExportImport/Import/A/deps_shared_iface.cpp @@ -12,6 +12,10 @@ #error Expected PIC_PROPERTY_IS_ON #endif +#ifndef CUSTOM_PROPERTY_IS_ON +#error Expected CUSTOM_PROPERTY_IS_ON +#endif + #ifdef TEST_SUBDIR_LIB #include "subdir.h" #endif -- cgit v0.12 From 0d46e9a0297d78dabc9988604a15c0096c702855 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 20 Jan 2013 12:28:59 +0100 Subject: Store includes from the same include_directories call together. Otherwise, we get a separate IncludeDirectoriesEntry for each include, and that causes unnecessary and confusing splitting in the output when debugging the INCLUDE_DIRECTORIES property. --- Source/cmFLTKWrapUICommand.cxx | 6 +- Source/cmIncludeDirectoryCommand.cxx | 92 ++++++++++++++-------- Source/cmIncludeDirectoryCommand.h | 3 +- Source/cmMakefile.cxx | 30 +++++-- Source/cmMakefile.h | 5 +- .../include_directories/DebugIncludes-stderr.txt | 7 -- 6 files changed, 91 insertions(+), 52 deletions(-) diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx index a4aa75a..b08c335 100644 --- a/Source/cmFLTKWrapUICommand.cxx +++ b/Source/cmFLTKWrapUICommand.cxx @@ -37,9 +37,13 @@ bool cmFLTKWrapUICommand // get the list of GUI files from which .cxx and .h will be generated std::string outputDirectory = this->Makefile->GetCurrentOutputDirectory(); + { // Some of the generated files are *.h so the directory "GUI" // where they are created have to be added to the include path - this->Makefile->AddIncludeDirectory( outputDirectory.c_str() ); + std::vector outputDirectories; + outputDirectories.push_back(outputDirectory); + this->Makefile->AddIncludeDirectories( outputDirectories ); + } for(std::vector::iterator i = (newArgs.begin() + 1); i != newArgs.end(); i++) diff --git a/Source/cmIncludeDirectoryCommand.cxx b/Source/cmIncludeDirectoryCommand.cxx index ba81849..671e09f 100644 --- a/Source/cmIncludeDirectoryCommand.cxx +++ b/Source/cmIncludeDirectoryCommand.cxx @@ -36,6 +36,10 @@ bool cmIncludeDirectoryCommand ++i; } + std::vector beforeIncludes; + std::vector afterIncludes; + std::set systemIncludes; + for(; i != args.end(); ++i) { if(*i == "SYSTEM") @@ -49,9 +53,37 @@ bool cmIncludeDirectoryCommand return false; } - this->AddDirectory(i->c_str(),before,system); + std::vector includes; + + GetIncludes(*i, includes); + if (before) + { + beforeIncludes.insert(beforeIncludes.end(), + includes.begin(), + includes.end()); + } + else + { + afterIncludes.insert(afterIncludes.end(), + includes.begin(), + includes.end()); + } + if (system) + { + for (std::vector::const_iterator li = includes.begin(); + li != includes.end(); ++li) + { + systemIncludes.insert(*li); + } + } } + std::reverse(beforeIncludes.begin(), beforeIncludes.end()); + + this->Makefile->AddIncludeDirectories(afterIncludes); + this->Makefile->AddIncludeDirectories(beforeIncludes, before); + this->Makefile->AddSystemIncludeDirectories(systemIncludes); + return true; } @@ -72,57 +104,49 @@ static bool StartsWithGeneratorExpression(const std::string &input) // output from a program and passing it into a command the cleanup doesn't // always happen // -void cmIncludeDirectoryCommand::AddDirectory(const char *i, - bool before, - bool system) +void cmIncludeDirectoryCommand::GetIncludes(const std::string &arg, + std::vector &incs) { // break apart any line feed arguments - std::string ret = i; std::string::size_type pos = 0; - if((pos = ret.find('\n', pos)) != std::string::npos) + std::string::size_type lastPos = 0; + while((pos = arg.find('\n', lastPos)) != std::string::npos) { if (pos) { - this->AddDirectory(ret.substr(0,pos).c_str(), before, system); - } - if (ret.size()-pos-1) - { - this->AddDirectory(ret.substr(pos+1,ret.size()-pos-1).c_str(), - before, system); + std::string inc = arg.substr(lastPos,pos); + NormalizeInclude(inc); + incs.push_back(inc); } - return; + lastPos = pos + 1; } + std::string inc = arg.substr(lastPos); + NormalizeInclude(inc); + incs.push_back(inc); +} - // remove any leading or trailing spaces and \r - std::string::size_type b = ret.find_first_not_of(" \r"); - std::string::size_type e = ret.find_last_not_of(" \r"); - if ((b!=ret.npos) && (e!=ret.npos)) - { - ret.assign(ret, b, 1+e-b); // copy the remaining substring - } - else +void cmIncludeDirectoryCommand::NormalizeInclude(std::string &inc) +{ + std::string::size_type b = inc.find_first_not_of(" \r"); + std::string::size_type e = inc.find_last_not_of(" \r"); + if ((b!=inc.npos) && (e!=inc.npos)) { - return; // if we get here, we had only whitespace in the string + inc.assign(inc, b, 1+e-b); // copy the remaining substring } - if (!cmSystemTools::IsOff(ret.c_str())) + if (!cmSystemTools::IsOff(inc.c_str())) { - cmSystemTools::ConvertToUnixSlashes(ret); - if(!cmSystemTools::FileIsFullPath(ret.c_str())) + cmSystemTools::ConvertToUnixSlashes(inc); + + if(!cmSystemTools::FileIsFullPath(inc.c_str())) { - if(!StartsWithGeneratorExpression(ret)) + if(!StartsWithGeneratorExpression(inc)) { std::string tmp = this->Makefile->GetStartDirectory(); tmp += "/"; - tmp += ret; - ret = tmp; + tmp += inc; + inc = tmp; } } } - this->Makefile->AddIncludeDirectory(ret.c_str(), before); - if(system) - { - this->Makefile->AddSystemIncludeDirectory(ret.c_str()); - } } - diff --git a/Source/cmIncludeDirectoryCommand.h b/Source/cmIncludeDirectoryCommand.h index dd37b82..a32fc77 100644 --- a/Source/cmIncludeDirectoryCommand.h +++ b/Source/cmIncludeDirectoryCommand.h @@ -84,7 +84,8 @@ public: protected: // used internally - void AddDirectory(const char *arg, bool before, bool system); + void GetIncludes(const std::string &arg, std::vector &incs); + void NormalizeInclude(std::string &inc); }; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index b432986..7e77664 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1616,20 +1616,31 @@ void cmMakefile::AddSubDirectory(const char* srcPath, const char *binPath, } //---------------------------------------------------------------------------- -void cmMakefile::AddIncludeDirectory(const char* inc, bool before) +void cmMakefile::AddIncludeDirectories(const std::vector &incs, + bool before) { - if (!inc) + if (incs.empty()) { return; } + std::string incString; + std::string sep; + + for(std::vector::const_iterator li = incs.begin(); + li != incs.end(); ++li) + { + incString += sep + *li; + sep = ";"; + } + std::vector::iterator position = - before ? this->IncludeDirectoriesEntries.begin() - : this->IncludeDirectoriesEntries.end(); + before ? this->IncludeDirectoriesEntries.begin() + : this->IncludeDirectoriesEntries.end(); cmListFileBacktrace lfbt; this->GetBacktrace(lfbt); - IncludeDirectoriesEntry entry(inc, lfbt); + IncludeDirectoriesEntry entry(incString, lfbt); this->IncludeDirectoriesEntries.insert(position, entry); // Property on each target: @@ -1642,9 +1653,14 @@ void cmMakefile::AddIncludeDirectory(const char* inc, bool before) } //---------------------------------------------------------------------------- -void cmMakefile::AddSystemIncludeDirectory(const char* dir) +void +cmMakefile::AddSystemIncludeDirectories(const std::set &incs) { - this->SystemIncludeDirectories.insert(dir); + for(std::set::const_iterator li = incs.begin(); + li != incs.end(); ++li) + { + this->SystemIncludeDirectories.insert(*li); + } } //---------------------------------------------------------------------------- diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index a85015f..bb161b1 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -287,7 +287,8 @@ public: /** * Add an include directory to the build. */ - void AddIncludeDirectory(const char*, bool before = false); + void AddIncludeDirectories(const std::vector &incs, + bool before = false); /** * Add a variable definition to the build. This variable @@ -545,7 +546,7 @@ public: /** * Mark include directories as system directories. */ - void AddSystemIncludeDirectory(const char* dir); + void AddSystemIncludeDirectories(const std::set &incs); bool IsSystemIncludeDirectory(const char* dir); /** Expand out any arguements in the vector that have ; separated diff --git a/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt b/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt index 948def1..ab99784 100644 --- a/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt +++ b/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt @@ -2,13 +2,6 @@ CMake Warning at DebugIncludes.cmake:8 \(include_directories\): Used includes: \* .*/Tests/RunCMake/include_directories/one - -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) -+ -CMake Warning at DebugIncludes.cmake:8 \(include_directories\): - Used includes: - \* .*/Tests/RunCMake/include_directories/two Call Stack \(most recent call first\): -- cgit v0.12 From d70204a86aa3e454e73049efda3e1ccea8c60720 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 20 Jan 2013 12:50:53 +0100 Subject: Only output includes once after the start of 'generate-time' when debugging. During configure-time, GetIncludeDirectories may be called too, for example if using the export() command. As the content can be different, it should be output each time then. --- Source/cmGlobalGenerator.cxx | 1 + Source/cmMakefile.cxx | 1 + Source/cmMakefile.h | 6 ++++++ Source/cmTarget.cxx | 9 ++++++++- Source/cmTarget.h | 1 + 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index d2baf53..f28bd6c 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -980,6 +980,7 @@ void cmGlobalGenerator::Generate() // Generate project files for (i = 0; i < this->LocalGenerators.size(); ++i) { + this->LocalGenerators[i]->GetMakefile()->SetGeneratingBuildSystem(); this->SetCurrentLocalGenerator(this->LocalGenerators[i]); this->LocalGenerators[i]->Generate(); this->LocalGenerators[i]->GenerateInstallRules(); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 7e77664..4721e4c 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -99,6 +99,7 @@ cmMakefile::cmMakefile(): Internal(new Internals) this->AddDefaultDefinitions(); this->Initialize(); this->PreOrder = false; + this->GeneratingBuildSystem = false; } cmMakefile::cmMakefile(const cmMakefile& mf): Internal(new Internals) diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index bb161b1..a2783f2 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -870,6 +870,9 @@ public: return this->IncludeDirectoriesEntries; } + bool IsGeneratingBuildSystem(){ return this->GeneratingBuildSystem; } + void SetGeneratingBuildSystem(){ this->GeneratingBuildSystem = true; } + protected: // add link libraries and directories to the target void AddGlobalLinkInformation(const char* name, cmTarget& target); @@ -1019,6 +1022,9 @@ private: // Enforce rules about CMakeLists.txt files. void EnforceDirectoryLevelRules(); + + bool GeneratingBuildSystem; + }; //---------------------------------------------------------------------------- diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 815da40..fb99b4a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -151,6 +151,7 @@ cmTarget::cmTarget() this->IsApple = false; this->IsImportedTarget = false; this->BuildInterfaceIncludesAppended = false; + this->DebugIncludesDone = false; } //---------------------------------------------------------------------------- @@ -2739,11 +2740,17 @@ std::vector cmTarget::GetIncludeDirectories(const char *config) cmSystemTools::ExpandListArgument(debugProp, debugProperties); } - bool debugIncludes = std::find(debugProperties.begin(), + bool debugIncludes = !this->DebugIncludesDone + && std::find(debugProperties.begin(), debugProperties.end(), "INCLUDE_DIRECTORIES") != debugProperties.end(); + if (this->Makefile->IsGeneratingBuildSystem()) + { + this->DebugIncludesDone = true; + } + for (std::vector::const_iterator it = this->Internal->IncludeDirectoriesEntries.begin(), end = this->Internal->IncludeDirectoriesEntries.end(); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 69a00c1..47ec528 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -610,6 +610,7 @@ private: bool DLLPlatform; bool IsApple; bool IsImportedTarget; + bool DebugIncludesDone; mutable std::map > LinkDependentProperties; mutable std::set LinkImplicitNullProperties; -- cgit v0.12 From aa6674831c3ea3bf3cca7c9f667d2e5c75873a3d Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 20 Jan 2013 12:57:25 +0100 Subject: Specify the target whose includes are being listed. --- Source/cmTarget.cxx | 4 ++-- Tests/RunCMake/include_directories/DebugIncludes-stderr.txt | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index fb99b4a..6c9ed1b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2785,8 +2785,8 @@ std::vector cmTarget::GetIncludeDirectories(const char *config) if (!usedIncludes.empty()) { this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, - "Used includes:\n" + usedIncludes, - (*it)->ge->GetBacktrace()); + "Used includes for target " + this->Name + ":\n" + + usedIncludes, (*it)->ge->GetBacktrace()); } } return includes; diff --git a/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt b/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt index ab99784..379174a 100644 --- a/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt +++ b/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt @@ -1,5 +1,5 @@ CMake Warning at DebugIncludes.cmake:8 \(include_directories\): - Used includes: + Used includes for target lll: \* .*/Tests/RunCMake/include_directories/one \* .*/Tests/RunCMake/include_directories/two @@ -8,7 +8,7 @@ Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) + CMake Warning at DebugIncludes.cmake:13 \(set_property\): - Used includes: + Used includes for target lll: \* .*/Tests/RunCMake/include_directories/three @@ -16,7 +16,7 @@ Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) + CMake Warning at DebugIncludes.cmake:18 \(include_directories\): - Used includes: + Used includes for target lll: \* .*/Tests/RunCMake/include_directories/four @@ -24,7 +24,7 @@ Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) + CMake Warning at DebugIncludes.cmake:25 \(set_property\): - Used includes: + Used includes for target lll: \* .*/Tests/RunCMake/include_directories/five \* .*/Tests/RunCMake/include_directories/six -- cgit v0.12 From 6063fef226d35aad0629d7098f72afa650e7a149 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 20 Jan 2013 13:07:31 +0100 Subject: Output include directories as LOG messages, not warnings. --- Source/cmake.cxx | 4 ++++ Tests/RunCMake/include_directories/DebugIncludes-stderr.txt | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 2eecfba..932c996 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -4394,6 +4394,10 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text, isError = true; msg << "CMake Internal Error (please report a bug)"; } + else if(t == cmake::LOG) + { + msg << "CMake Debug Log"; + } else { msg << "CMake Warning"; diff --git a/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt b/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt index 379174a..736fe69 100644 --- a/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt +++ b/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt @@ -1,4 +1,4 @@ -CMake Warning at DebugIncludes.cmake:8 \(include_directories\): +CMake Debug Log at DebugIncludes.cmake:8 \(include_directories\): Used includes for target lll: \* .*/Tests/RunCMake/include_directories/one @@ -7,7 +7,7 @@ CMake Warning at DebugIncludes.cmake:8 \(include_directories\): Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) + -CMake Warning at DebugIncludes.cmake:13 \(set_property\): +CMake Debug Log at DebugIncludes.cmake:13 \(set_property\): Used includes for target lll: \* .*/Tests/RunCMake/include_directories/three @@ -15,7 +15,7 @@ CMake Warning at DebugIncludes.cmake:13 \(set_property\): Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) + -CMake Warning at DebugIncludes.cmake:18 \(include_directories\): +CMake Debug Log at DebugIncludes.cmake:18 \(include_directories\): Used includes for target lll: \* .*/Tests/RunCMake/include_directories/four @@ -23,7 +23,7 @@ CMake Warning at DebugIncludes.cmake:18 \(include_directories\): Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) + -CMake Warning at DebugIncludes.cmake:25 \(set_property\): +CMake Debug Log at DebugIncludes.cmake:25 \(set_property\): Used includes for target lll: \* .*/Tests/RunCMake/include_directories/five -- cgit v0.12 From 48a4cf21825c9ed5f53ac25d5f4577baaf92d1f7 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 21 Jan 2013 12:05:01 +0100 Subject: Revert "Allow target_link_libraries with IMPORTED targets." This reverts commit 9cfe4f1b769597bd9ba179eba46572a9df27f64c. It turns out that correctly adding the content to the IMPORTED_LINK_INTERFACE_LIBARIES_ of an upstream target from the buildsystem of a downstream project is not simple. If upstream had added the INTERFACE content, the config-specific properties would be determined by the DEBUG_CONFIGURATIONS of upstream. As downstream, we don't have any information about what the DEBUG_CONFIGURATIONS of upstream were, so we can't determine which configuration-specific properties to populate. The best we can do is add it to all of them or add it to the ones downstream considers to be DEBUG_CONFIGURATIONS, neither of which is a good solution. So, removing the porcelain API for that is the best approach. A human can still determine which properties to populate and use the set_property API to populate the desired properies. Another solution to this would be for upstream targets to publish what they consider DEBUG_CONFIGURATIONS, but that can be added in a future release. --- Source/cmTargetLinkLibrariesCommand.cxx | 14 -------------- Tests/CMakeCommands/target_link_libraries/CMakeLists.txt | 3 --- 2 files changed, 17 deletions(-) diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index 0705fb4..f42b0f6 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -35,10 +35,6 @@ bool cmTargetLinkLibrariesCommand ->GetGlobalGenerator()->FindTarget(0, args[0].c_str()); if(!this->Target) { - this->Target = this->Makefile->FindTargetToUse(args[0].c_str()); - } - if(!this->Target) - { cmake::MessageType t = cmake::FATAL_ERROR; // fail by default cmOStringStream e; e << "Cannot specify link libraries for target \"" << args[0] << "\" " @@ -261,16 +257,6 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib, // Handle normal case first. if(this->CurrentProcessingState != ProcessingLinkInterface) { - if (this->Target->IsImported()) - { - cmOStringStream e; - e << "Imported targets may only be used with the " - "LINK_INTERFACE_LIBRARIES specifier to target_link_libraries."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); - return; - } - - this->Makefile ->AddLinkLibraryForTarget(this->Target->GetName(), lib, llt); if (this->CurrentProcessingState != ProcessingPublicInterface) diff --git a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt index 1551c50..1d0e342 100644 --- a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt +++ b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt @@ -29,9 +29,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) add_library(depA SHARED depA.cpp) generate_export_header(depA) -add_library(importedlib UNKNOWN IMPORTED) -target_link_libraries(importedlib LINK_INTERFACE_LIBRARIES depA) - add_library(depB SHARED depB.cpp) generate_export_header(depB) -- cgit v0.12 From b98d14d40016efee420bee26b9795880fdf6a5f8 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 21 Jan 2013 12:28:27 +0100 Subject: Disallow porcelain to populate includes and defines of IMPORTED targets. With similar reasoning to the parent commit, as downstreams, we can't determine what $ generator expressions would be appropriate. Upstream would have populated the INTERFACE_INCLUDE_DIRECTORIES with config-specific generator expressions, possibly appropriate for their DEBUG_CONFIGURATIONS. In theory, if we would add include directories for a DEBUG intent, we would have to match the upstream configurations for that. Rather than attempting to discover the appropriate configurations at this time, simplify the feature instead. The use of IMPORTED targets with these commands could still be added in the future if targets would export their DEBUG_CONFIGURATIONS somehow. --- Source/cmTargetCompileDefinitionsCommand.cxx | 8 +++----- Source/cmTargetCompileDefinitionsCommand.h | 5 ++--- Source/cmTargetIncludeDirectoriesCommand.cxx | 8 +++----- Source/cmTargetIncludeDirectoriesCommand.h | 5 ++--- Source/cmTargetPropCommandBase.cxx | 4 ++-- Source/cmTargetPropCommandBase.h | 3 +-- Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt | 7 +------ Tests/CMakeCommands/target_compile_definitions/consumer.cpp | 4 ---- Tests/CMakeCommands/target_include_directories/CMakeLists.txt | 10 +--------- Tests/CMakeCommands/target_include_directories/consumer.cpp | 5 ----- 10 files changed, 15 insertions(+), 44 deletions(-) diff --git a/Source/cmTargetCompileDefinitionsCommand.cxx b/Source/cmTargetCompileDefinitionsCommand.cxx index 492a1b7..683eff6 100644 --- a/Source/cmTargetCompileDefinitionsCommand.cxx +++ b/Source/cmTargetCompileDefinitionsCommand.cxx @@ -20,13 +20,11 @@ bool cmTargetCompileDefinitionsCommand } void cmTargetCompileDefinitionsCommand -::HandleImportedTargetInvalidScope(const std::string &scope, - const std::string &tgt) +::HandleImportedTarget(const std::string &tgt) { cmOStringStream e; - e << "Cannot specify " << scope << " compile definitions for imported " - "target \"" << tgt << "\". Compile definitions can only be " - "specified for an imported target in the INTERFACE mode."; + e << "Cannot specify compile definitions for imported target \"" + << tgt << "\"."; this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); } diff --git a/Source/cmTargetCompileDefinitionsCommand.h b/Source/cmTargetCompileDefinitionsCommand.h index 4b066b7a..d49b9e8 100644 --- a/Source/cmTargetCompileDefinitionsCommand.h +++ b/Source/cmTargetCompileDefinitionsCommand.h @@ -59,7 +59,7 @@ public: "Specify compile definitions or targets to use when compiling a given " "target. " "The named must have been created by a command such as " - "add_executable or add_library. " + "add_executable or add_library and must not be an IMPORTED target. " "The INTERFACE, PUBLIC and PRIVATE keywords are required to specify " "the scope of the following arguments. PRIVATE and PUBLIC items will " "populate the COMPILE_DEFINITIONS property of . PUBLIC and " @@ -78,8 +78,7 @@ public: cmTypeMacro(cmTargetCompileDefinitionsCommand, cmCommand); private: - virtual void HandleImportedTargetInvalidScope(const std::string &scope, - const std::string &tgt); + virtual void HandleImportedTarget(const std::string &tgt); virtual void HandleMissingTarget(const std::string &name); virtual bool HandleNonTargetArg(std::string &content, diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx index 18e2cba..aeba468 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.cxx +++ b/Source/cmTargetIncludeDirectoriesCommand.cxx @@ -22,13 +22,11 @@ bool cmTargetIncludeDirectoriesCommand //---------------------------------------------------------------------------- void cmTargetIncludeDirectoriesCommand -::HandleImportedTargetInvalidScope(const std::string &tgt, - const std::string &scope) +::HandleImportedTarget(const std::string &tgt) { cmOStringStream e; - e << "Cannot specify " << scope << " include directories for imported " - "target \"" << tgt << "\". Include directories can only be " - "specified for an imported target in the INTERFACE mode."; + e << "Cannot specify include directories for imported target \"" + << tgt << "\"."; this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); } diff --git a/Source/cmTargetIncludeDirectoriesCommand.h b/Source/cmTargetIncludeDirectoriesCommand.h index 90e039c..5a5f859 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.h +++ b/Source/cmTargetIncludeDirectoriesCommand.h @@ -60,7 +60,7 @@ public: "Specify include directories or targets to use when compiling a given " "target. " "The named must have been created by a command such as " - "add_executable or add_library.\n" + "add_executable or add_library and must not be an IMPORTED target.\n" "If BEFORE is specified, the content will be prepended to the property " "instead of being appended.\n" "The INTERFACE, PUBLIC and PRIVATE keywords are required to specify " @@ -82,8 +82,7 @@ public: cmTypeMacro(cmTargetIncludeDirectoriesCommand, cmCommand); private: - virtual void HandleImportedTargetInvalidScope(const std::string &tgt, - const std::string &scope); + virtual void HandleImportedTarget(const std::string &tgt); virtual void HandleMissingTarget(const std::string &name); virtual bool HandleNonTargetArg(std::string &content, diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx index 69aaf17..c79c16f 100644 --- a/Source/cmTargetPropCommandBase.cxx +++ b/Source/cmTargetPropCommandBase.cxx @@ -80,9 +80,9 @@ bool cmTargetPropCommandBase return false; } - if(this->Target->IsImported() && scope != "INTERFACE") + if(this->Target->IsImported()) { - this->HandleImportedTargetInvalidScope(args[0], scope); + this->HandleImportedTarget(args[0]); return false; } diff --git a/Source/cmTargetPropCommandBase.h b/Source/cmTargetPropCommandBase.h index e757f9d..15a78c9 100644 --- a/Source/cmTargetPropCommandBase.h +++ b/Source/cmTargetPropCommandBase.h @@ -32,8 +32,7 @@ public: const char *prop, ArgumentFlags flags = NO_FLAGS); private: - virtual void HandleImportedTargetInvalidScope(const std::string &tgt, - const std::string &scope) = 0; + virtual void HandleImportedTarget(const std::string &tgt) = 0; virtual void HandleMissingTarget(const std::string &name) = 0; virtual bool HandleNonTargetArg(std::string &content, diff --git a/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt index a37c597..3eca7fc 100644 --- a/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt +++ b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt @@ -12,11 +12,6 @@ target_compile_definitions(target_compile_definitions INTERFACE MY_INTERFACE_DEFINE ) -add_library(importedlib UNKNOWN IMPORTED) -target_compile_definitions(importedlib - INTERFACE MY_IMPORTEDINTERFACE_DEFINE -) - add_executable(consumer "${CMAKE_CURRENT_SOURCE_DIR}/consumer.cpp" ) @@ -24,5 +19,5 @@ add_executable(consumer target_compile_definitions(consumer PRIVATE target_compile_definitions importedlib $<$:SHOULD_NOT_BE_DEFINED> - $<$:SHOULD_BE_DEFINED> + $<$:SHOULD_BE_DEFINED> ) diff --git a/Tests/CMakeCommands/target_compile_definitions/consumer.cpp b/Tests/CMakeCommands/target_compile_definitions/consumer.cpp index 1ef657d..f835b6c 100644 --- a/Tests/CMakeCommands/target_compile_definitions/consumer.cpp +++ b/Tests/CMakeCommands/target_compile_definitions/consumer.cpp @@ -11,10 +11,6 @@ #error Expected MY_INTERFACE_DEFINE #endif -#ifndef MY_IMPORTEDINTERFACE_DEFINE -#error Expected MY_IMPORTEDINTERFACE_DEFINE -#endif - #ifdef SHOULD_NOT_BE_DEFINED #error Unexpected SHOULD_NOT_BE_DEFINED #endif diff --git a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt index a0f2ee0..486bca0 100644 --- a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt +++ b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt @@ -11,9 +11,6 @@ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/publicinclude/publicinclude.h" "#define file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/interfaceinclude") file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/interfaceinclude/interfaceinclude.h" "#define INTERFACEINCLUDE_DEFINE\n") -file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/importedinterfaceinclude") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/importedinterfaceinclude/importedinterfaceinclude.h" "#define IMPORTEDINTERFACEINCLUDE_DEFINE\n") - file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/poison") file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/poison/common.h" "#error Should not be included\n") @@ -36,15 +33,10 @@ target_include_directories(target_include_directories BEFORE PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/cure" ) -add_library(importedlib UNKNOWN IMPORTED) -target_include_directories(importedlib - INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/importedinterfaceinclude" -) - add_executable(consumer "${CMAKE_CURRENT_SOURCE_DIR}/consumer.cpp" ) target_include_directories(consumer - PRIVATE target_include_directories importedlib + PRIVATE target_include_directories ) diff --git a/Tests/CMakeCommands/target_include_directories/consumer.cpp b/Tests/CMakeCommands/target_include_directories/consumer.cpp index 6fd61d5..5d88488 100644 --- a/Tests/CMakeCommands/target_include_directories/consumer.cpp +++ b/Tests/CMakeCommands/target_include_directories/consumer.cpp @@ -2,7 +2,6 @@ #include "common.h" #include "publicinclude.h" #include "interfaceinclude.h" -#include "importedinterfaceinclude.h" #ifdef PRIVATEINCLUDE_DEFINE #error Unexpected PRIVATEINCLUDE_DEFINE @@ -16,10 +15,6 @@ #error Expected INTERFACEINCLUDE_DEFINE #endif -#ifndef IMPORTEDINTERFACEINCLUDE_DEFINE -#error Expected IMPORTEDINTERFACEINCLUDE_DEFINE -#endif - #ifndef CURE_DEFINE #error Expected CURE_DEFINE #endif -- cgit v0.12 From 2db9b0b06638ee9386391369823c204ea691576e Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Tue, 22 Jan 2013 00:01:18 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 45fc936..f56e894 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130121) +set(CMake_VERSION_TWEAK 20130122) #set(CMake_VERSION_RC 1) -- cgit v0.12 From a40c4261e6e9eef4fae5266b14a3790ee76f4612 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Wed, 23 Jan 2013 00:01:06 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index f56e894..623b708 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130122) +set(CMake_VERSION_TWEAK 20130123) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 3853a6c3a7210c29f82fd27f9d2f6e99eb18e1ba Mon Sep 17 00:00:00 2001 From: "Yury G. Kudryashov" Date: Tue, 22 Jan 2013 06:44:08 +0400 Subject: spell: fix a few typos in comments --- Source/cmMakefile.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index b432986..d1dc5a2 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2243,7 +2243,7 @@ bool cmMakefile::CanIWriteThisFile(const char* fileName) { return true; } - // If we are doing an in-source build, than the test will always fail + // If we are doing an in-source build, then the test will always fail if ( cmSystemTools::SameFile(this->GetHomeDirectory(), this->GetHomeOutputDirectory()) ) { @@ -2254,8 +2254,8 @@ bool cmMakefile::CanIWriteThisFile(const char* fileName) return true; } - // Check if this is subdirectory of the source tree but not a - // subdirectory of a build tree + // Check if this is a subdirectory of the source tree but not a + // subdirectory of the build tree if ( cmSystemTools::IsSubDirectory(fileName, this->GetHomeDirectory()) && !cmSystemTools::IsSubDirectory(fileName, -- cgit v0.12 From e3b5eb6b23e5d2b6034e1c13716abb73ab6b3397 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 20 Nov 2012 14:53:41 +0100 Subject: Automatically link to the qtmain library when linking to QtCore. When using QAxServer, ensure that the qtmain library is excluded by reporting an error at CMake time if it is not. --- Modules/FindQt4.cmake | 28 ++++++++++++++++++++++++ Source/cmGeneratorExpressionEvaluator.cxx | 7 ++++-- Source/cmPolicies.cxx | 21 ++++++++++++++++++ Source/cmPolicies.h | 1 + Source/cmTarget.cxx | 3 +++ Source/cmTarget.h | 5 +++++ Tests/Qt4Targets/CMakeLists.txt | 27 +++++++++++++++++++---- Tests/Qt4Targets/activeqtexe.cpp | 36 +++++++++++++++++++++++++++++++ 8 files changed, 122 insertions(+), 6 deletions(-) create mode 100644 Tests/Qt4Targets/activeqtexe.cpp diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index 7baa11b..35420b4 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -65,6 +65,12 @@ # is much more flexible, but requires that FindQt4.cmake is executed before # such an exported dependency file is processed. # +# Note that if using IMPORTED targets, the qtmain.lib static library is +# automatically linked on Windows. To disable that globally, set the +# QT4_NO_LINK_QTMAIN variable before finding Qt4. To disable that for a +# particular executable, set the QT4_NO_LINK_QTMAIN target property to +# True on the executable. +# # QT_INCLUDE_DIRS_NO_SYSTEM # If this variable is set to TRUE, the Qt include directories # in the QT_USE_FILE will NOT have the SYSTEM keyword set. @@ -1009,7 +1015,14 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION) # platform dependent libraries if(Q_WS_WIN) _QT4_ADJUST_LIB_VARS(qtmain) + _QT4_ADJUST_LIB_VARS(QAxServer) + set_property(TARGET Qt4::QAxServer PROPERTY + INTERFACE_QT4_NO_LINK_QTMAIN ON + ) + set_property(TARGET Qt4::QAxServer APPEND PROPERTY + COMPATIBLE_INTERFACE_BOOL QT4_NO_LINK_QTMAIN) + _QT4_ADJUST_LIB_VARS(QAxContainer) endif() @@ -1049,6 +1062,21 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION) _qt4_add_target_private_depends(phonon DBus) endif() + if (WIN32 AND NOT QT4_NO_LINK_QTMAIN) + set(_isExe $,EXECUTABLE>) + set(_isWin32 $>) + set(_isNotExcluded $>>) + set(_isPolicyNEW $) + set_property(TARGET Qt4::QtCore APPEND PROPERTY + IMPORTED_LINK_INTERFACE_LIBRARIES + $<$:Qt4::qtmain> + ) + unset(_isExe) + unset(_isWin32) + unset(_isNotExcluded) + unset(_isPolicyNEW) + endif() + ####################################### # # Check the executables of Qt diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 2ddc058..c791977 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -492,6 +492,7 @@ static const char* targetPolicyWhitelist[] = { "CMP0003" , "CMP0004" , "CMP0008" + , "CMP0020" }; cmPolicies::PolicyStatus statusForTarget(cmTarget *tgt, const char *policy) @@ -505,6 +506,7 @@ cmPolicies::PolicyStatus statusForTarget(cmTarget *tgt, const char *policy) RETURN_POLICY(CMP0003) RETURN_POLICY(CMP0004) RETURN_POLICY(CMP0008) + RETURN_POLICY(CMP0020) #undef RETURN_POLICY @@ -523,6 +525,7 @@ cmPolicies::PolicyID policyForString(const char *policy_id) RETURN_POLICY_ID(CMP0003) RETURN_POLICY_ID(CMP0004) RETURN_POLICY_ID(CMP0008) + RETURN_POLICY_ID(CMP0020) #undef RETURN_POLICY_ID @@ -575,8 +578,8 @@ static const struct TargetPolicyNode : public cmGeneratorExpressionNode } reportError(context, content->GetOriginalExpression(), "$ may only be used with a limited number of " - "policies. Currently it may be used with policies CMP0003, CMP0004 " - "and CMP0008." + "policies. Currently it may be used with policies CMP0003, CMP0004, " + "CMP0008 and CMP0020." ); return std::string(); } diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index eb7d666..831e92e 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -508,6 +508,27 @@ cmPolicies::cmPolicies() "for strict compatibility. " "The NEW behavior for this policy is to leave the values untouched.", 2,8,11,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0020, "CMP0020", + "Automatically link Qt executables to qtmain target on Windows.", + "CMake 2.8.10 and lower required users of Qt to always specify a link " + "dependency to the qtmain.lib static library manually on Windows. CMake " + "2.8.11 gained the ability to evaluate generator expressions while " + "determining the link dependencies from IMPORTED targets. This allows " + "CMake itself to automatically link executables which link to Qt to the " + "qtmain.lib library when using IMPORTED Qt targets. For applications " + "already linking to qtmain.lib, this should have little impact. For " + "applications which supply their own alternative WinMain implementation " + "and for applications which use the QAxServer library, this automatic " + "linking will need to be disabled as per the documentation." + "\n" + "The OLD behavior for this policy is not to link executables to " + "qtmain.lib automatically when they link to the QtCore IMPORTED" + "target. " + "The NEW behavior for this policy is to link executables to " + "qtmain.lib automatically when they link to QtCore IMPORTED target.", + 2,8,11,0, cmPolicies::WARN); } cmPolicies::~cmPolicies() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index d7d945c..c11af07 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -69,6 +69,7 @@ public: /// POSITION_INDEPENDENT_CODE property and *_COMPILE_OPTIONS_PI{E,C} /// instead. CMP0019, ///< No variable re-expansion in include and link info + CMP0020, ///< Automatically link Qt executables to qtmain target /** \brief Always the last entry. * diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 45862fb..d1bd4a6 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -145,6 +145,7 @@ cmTarget::cmTarget() this->PolicyStatusCMP0003 = cmPolicies::WARN; this->PolicyStatusCMP0004 = cmPolicies::WARN; this->PolicyStatusCMP0008 = cmPolicies::WARN; + this->PolicyStatusCMP0020 = cmPolicies::WARN; this->LinkLibrariesAnalyzed = false; this->HaveInstallRule = false; this->DLLPlatform = false; @@ -1499,6 +1500,8 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->Makefile->GetPolicyStatus(cmPolicies::CMP0004); this->PolicyStatusCMP0008 = this->Makefile->GetPolicyStatus(cmPolicies::CMP0008); + this->PolicyStatusCMP0020 = + this->Makefile->GetPolicyStatus(cmPolicies::CMP0020); } //---------------------------------------------------------------------------- diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 69a00c1..ea3b823 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -102,6 +102,10 @@ public: cmPolicies::PolicyStatus GetPolicyStatusCMP0008() const { return this->PolicyStatusCMP0008; } + /** Get the status of policy CMP0020 when the target was created. */ + cmPolicies::PolicyStatus GetPolicyStatusCMP0020() const + { return this->PolicyStatusCMP0020; } + /** * Get the list of the custom commands for this target */ @@ -656,6 +660,7 @@ private: cmPolicies::PolicyStatus PolicyStatusCMP0003; cmPolicies::PolicyStatus PolicyStatusCMP0004; cmPolicies::PolicyStatus PolicyStatusCMP0008; + cmPolicies::PolicyStatus PolicyStatusCMP0020; // Internal representation details. friend class cmTargetInternals; diff --git a/Tests/Qt4Targets/CMakeLists.txt b/Tests/Qt4Targets/CMakeLists.txt index 9bd7a64..d3aba74 100644 --- a/Tests/Qt4Targets/CMakeLists.txt +++ b/Tests/Qt4Targets/CMakeLists.txt @@ -2,15 +2,16 @@ cmake_minimum_required(VERSION 2.8) project(Qt4Targets) +cmake_policy(SET CMP0020 NEW) + find_package(Qt4 REQUIRED) +set(CMAKE_AUTOMOC ON) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + add_executable(Qt4Targets WIN32 main.cpp) target_link_libraries(Qt4Targets Qt4::QtGui) -if (WIN32) - target_link_libraries(Qt4Targets Qt4::qtmain) -endif() - set_property(TARGET Qt4Targets APPEND PROPERTY INCLUDE_DIRECTORIES $ @@ -19,3 +20,21 @@ set_property(TARGET Qt4Targets APPEND PROPERTY COMPILE_DEFINITIONS $ ) + +if (WIN32) + if (TARGET Qt4::QAxServer) + add_executable(activeqtexe WIN32 activeqtexe.cpp) + set_property(TARGET activeqtexe PROPERTY QT4_NO_LINK_QTMAIN ON) + target_link_libraries(activeqtexe Qt4::QAxServer Qt4::QtGui) + set_property(TARGET activeqtexe APPEND PROPERTY + INCLUDE_DIRECTORIES + $ + $ + ) + set_property(TARGET activeqtexe APPEND PROPERTY + COMPILE_DEFINITIONS + $ + $ + ) + endif() +endif() diff --git a/Tests/Qt4Targets/activeqtexe.cpp b/Tests/Qt4Targets/activeqtexe.cpp new file mode 100644 index 0000000..d4a9121 --- /dev/null +++ b/Tests/Qt4Targets/activeqtexe.cpp @@ -0,0 +1,36 @@ + +#include + +#ifndef QT_QAXSERVER_LIB +#error Expected QT_QAXSERVER_LIB +#endif + +#include + +class MyObject : public QObject +{ + Q_OBJECT +public: + MyObject(QObject *parent = 0) + : QObject(parent) + { + } +}; + +QAXFACTORY_DEFAULT(MyObject, + "{4dc3f340-a6f7-44e4-a79b-3e9217685fbd}", + "{9ee49617-7d5c-441a-b833-4b068d41d751}", + "{13eca64b-ee2a-4f3c-aa04-5d9d975779a7}", + "{ce947ee3-0403-4fdc-895a-4fe779344b46}", + "{8de435ce-8d2a-46ac-b3b3-cb800d0547c7}"); + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + QAxFactory::isServer(); + + return app.exec(); +} + +#include "activeqtexe.moc" -- cgit v0.12 From 2cf9642e9ca70f005e3ea59ab219afe8d16b31fc Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Thu, 24 Jan 2013 00:01:18 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 623b708..2c688b7 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130123) +set(CMake_VERSION_TWEAK 20130124) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 6fbe3ce4ef1178cc4f2f14f281cd48ef82a11e03 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 23 Jan 2013 22:17:14 +0100 Subject: Exclude the LINK_LIBRARIES related properties from INTERFACE evaluation. These interface-related link-libraries properties are used to determine the value of the other INTERFACE properties, so we were getting infinite recursion and segfaults otherwise. --- Source/cmGeneratorExpressionDAGChecker.cxx | 10 ++++++++-- Tests/CompatibleInterface/CMakeLists.txt | 16 ++++++++++++++++ Tests/CompatibleInterface/iface2.cpp | 7 +++++++ Tests/CompatibleInterface/iface2.h | 13 +++++++++++++ Tests/CompatibleInterface/main.cpp | 5 ++++- 5 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 Tests/CompatibleInterface/iface2.cpp create mode 100644 Tests/CompatibleInterface/iface2.h diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index 057f4c3..269211b 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -114,8 +114,14 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries() const cmGeneratorExpressionDAGChecker *parent = this->Parent; while (parent) { - parent = parent->Parent; top = parent; + parent = parent->Parent; } - return top->Property == "LINK_LIBRARIES"; + + const char *prop = top->Property.c_str(); + return (strcmp(prop, "LINK_LIBRARIES") == 0 + || strcmp(prop, "LINK_INTERFACE_LIBRARIES") == 0 + || strcmp(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES") == 0 + || strncmp(prop, "LINK_INTERFACE_LIBRARIES_", 26) == 0 + || strncmp(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES_", 35) == 0); } diff --git a/Tests/CompatibleInterface/CMakeLists.txt b/Tests/CompatibleInterface/CMakeLists.txt index d0eb60f..7280652 100644 --- a/Tests/CompatibleInterface/CMakeLists.txt +++ b/Tests/CompatibleInterface/CMakeLists.txt @@ -3,12 +3,16 @@ cmake_minimum_required(VERSION 2.8) project(CompatibleInterface) +include(GenerateExportHeader) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + add_library(iface1 empty.cpp) set_property(TARGET iface1 APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL BOOL_PROP1 BOOL_PROP2 BOOL_PROP3 + BOOL_PROP4 ) set_property(TARGET iface1 PROPERTY INTERFACE_BOOL_PROP1 ON) @@ -26,3 +30,15 @@ target_compile_definitions(CompatibleInterface $<$>:BOOL_PROP2> $<$>:BOOL_PROP3> ) + + +add_library(iface2 SHARED iface2.cpp) +generate_export_header(iface2) + +# For the LINK_LIBRARIES and related properties, we should not evaluate +# properties defined only in the interface - they should be implicitly zero +set_property(TARGET iface2 + APPEND PROPERTY + LINK_INTERFACE_LIBRARIES $<$>:nonexistant> +) +target_link_libraries(CompatibleInterface iface2) diff --git a/Tests/CompatibleInterface/iface2.cpp b/Tests/CompatibleInterface/iface2.cpp new file mode 100644 index 0000000..a9b5015 --- /dev/null +++ b/Tests/CompatibleInterface/iface2.cpp @@ -0,0 +1,7 @@ + +#include "iface2.h" + +int Iface2::foo() +{ + return 0; +} diff --git a/Tests/CompatibleInterface/iface2.h b/Tests/CompatibleInterface/iface2.h new file mode 100644 index 0000000..ef4ebee --- /dev/null +++ b/Tests/CompatibleInterface/iface2.h @@ -0,0 +1,13 @@ + +#ifndef IFACE2_H +#define IFACE2_H + +#include "iface2_export.h" + +class IFACE2_EXPORT Iface2 +{ +public: + int foo(); +}; + +#endif diff --git a/Tests/CompatibleInterface/main.cpp b/Tests/CompatibleInterface/main.cpp index b7c6638..ae0e985 100644 --- a/Tests/CompatibleInterface/main.cpp +++ b/Tests/CompatibleInterface/main.cpp @@ -11,7 +11,10 @@ #error Expected BOOL_PROP3 #endif +#include "iface2.h" + int main(int argc, char **argv) { - return 0; + Iface2 if2; + return if2.foo(); } -- cgit v0.12 From cd66b9131d76984795c8a77353d6afa33abb54f7 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 6 Jan 2013 13:49:16 +0100 Subject: Make calculation of link-interface-dependent properties type-sensitive. --- Source/cmTarget.cxx | 166 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 118 insertions(+), 48 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 2b912f3..d2839c5 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4500,22 +4500,50 @@ void cmTarget::AddLinkDependentTargetsForProperties( } //---------------------------------------------------------------------------- -bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, - const char *config) +template +PropertyType getTypedProperty(cmTarget *tgt, const char *prop, + PropertyType *); + +//---------------------------------------------------------------------------- +template<> +bool getTypedProperty(cmTarget *tgt, const char *prop, bool *) { - bool propContent = this->GetPropertyAsBool(p.c_str()); - const bool explicitlySet = this->GetProperties() + return tgt->GetPropertyAsBool(prop); +} + +//---------------------------------------------------------------------------- +template +bool consistentProperty(PropertyType lhs, PropertyType rhs); + +//---------------------------------------------------------------------------- +template<> +bool consistentProperty(bool lhs, bool rhs) +{ + return lhs == rhs; +} + +//---------------------------------------------------------------------------- +template +PropertyType checkInterfacePropertyCompatibility(cmTarget *tgt, + const std::string &p, + const char *config, + const char *defaultValue, + PropertyType *) +{ + PropertyType propContent = getTypedProperty(tgt, p.c_str(), + 0); + const bool explicitlySet = tgt->GetProperties() .find(p.c_str()) - != this->GetProperties().end(); + != tgt->GetProperties().end(); std::set dependentTargets; - this->GetLinkDependentTargetsForProperty(p, + tgt->GetLinkDependentTargetsForProperty(p, dependentTargets); const bool impliedByUse = - this->IsNullImpliedByLinkLibraries(p); + tgt->IsNullImpliedByLinkLibraries(p); assert((impliedByUse ^ explicitlySet) || (!impliedByUse && !explicitlySet)); - cmComputeLinkInformation *info = this->GetLinkInformation(config); + cmComputeLinkInformation *info = tgt->GetLinkInformation(config); const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); bool propInitialized = explicitlySet; @@ -4537,17 +4565,18 @@ bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, const bool ifaceIsSet = li->Target->GetProperties() .find("INTERFACE_" + p) != li->Target->GetProperties().end(); - const bool ifacePropContent = li->Target->GetPropertyAsBool( - ("INTERFACE_" + p).c_str()); + PropertyType ifacePropContent = + getTypedProperty(li->Target, + ("INTERFACE_" + p).c_str(), 0); if (explicitlySet) { if (ifaceIsSet) { - if (propContent != ifacePropContent) + if (!consistentProperty(propContent, ifacePropContent)) { cmOStringStream e; e << "Property " << p << " on target \"" - << this->GetName() << "\" does\nnot match the " + << tgt->GetName() << "\" does\nnot match the " "INTERFACE_" << p << " property requirement\nof " "dependency \"" << li->Target->GetName() << "\".\n"; cmSystemTools::Error(e.str().c_str()); @@ -4569,13 +4598,13 @@ bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, { if (ifaceIsSet) { - if (propContent != ifacePropContent) + if (!consistentProperty(propContent, ifacePropContent)) { cmOStringStream e; e << "Property " << p << " on target \"" - << this->GetName() << "\" is\nimplied to be FALSE because it " - "was used to determine the link libraries\nalready. The " - "INTERFACE_" << p << " property on\ndependency \"" + << tgt->GetName() << "\" is\nimplied to be " << defaultValue + << " because it was used to determine the link libraries\n" + "already. The INTERFACE_" << p << " property on\ndependency \"" << li->Target->GetName() << "\" is in conflict.\n"; cmSystemTools::Error(e.str().c_str()); break; @@ -4598,13 +4627,13 @@ bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, { if (propInitialized) { - if (propContent != ifacePropContent) + if (!consistentProperty(propContent, ifacePropContent)) { cmOStringStream e; e << "The INTERFACE_" << p << " property of \"" << li->Target->GetName() << "\" does\nnot agree with the value " "of " << p << " already determined\nfor \"" - << this->GetName() << "\".\n"; + << tgt->GetName() << "\".\n"; cmSystemTools::Error(e.str().c_str()); break; } @@ -4631,6 +4660,14 @@ bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, } //---------------------------------------------------------------------------- +bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, + const char *config) +{ + return checkInterfacePropertyCompatibility(this, p, config, "FALSE", + 0); +} + +//---------------------------------------------------------------------------- bool isLinkDependentProperty(cmTarget *tgt, const std::string &p, const char *interfaceProperty, const char *config) @@ -5417,6 +5454,64 @@ std::string cmTarget::CheckCMP0004(std::string const& item) return lib; } +template +PropertyType getLinkInterfaceDependentProperty(cmTarget *tgt, + const std::string prop, + const char *config, + PropertyType *); + +template<> +bool getLinkInterfaceDependentProperty(cmTarget *tgt, + const std::string prop, + const char *config, bool *) +{ + return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); +} + +//---------------------------------------------------------------------------- +template +void checkPropertyConsistency(cmTarget *depender, cmTarget *dependee, + const char *propName, + std::set &emitted, + const char *config, + PropertyType *) +{ + const char *prop = dependee->GetProperty(propName); + if (!prop) + { + return; + } + + std::vector props; + cmSystemTools::ExpandListArgument(prop, props); + + for(std::vector::iterator pi = props.begin(); + pi != props.end(); ++pi) + { + if (depender->GetMakefile()->GetCMakeInstance() + ->GetIsPropertyDefined(pi->c_str(), + cmProperty::TARGET)) + { + cmOStringStream e; + e << "Target \"" << dependee->GetName() << "\" has property \"" + << *pi << "\" listed in its " << propName << " property. " + "This is not allowed. Only user-defined properties may appear " + "listed in the " << propName << " property."; + depender->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str()); + return; + } + if(emitted.insert(*pi).second) + { + getLinkInterfaceDependentProperty(depender, *pi, config, + 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + } + } +} + //---------------------------------------------------------------------------- void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, const char* config) @@ -5433,38 +5528,13 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, { continue; } - const char *prop = li->Target->GetProperty("COMPATIBLE_INTERFACE_BOOL"); - if (!prop) - { - continue; - } - - std::vector props; - cmSystemTools::ExpandListArgument(prop, props); - for(std::vector::iterator pi = props.begin(); - pi != props.end(); ++pi) + checkPropertyConsistency(this, li->Target, + "COMPATIBLE_INTERFACE_BOOL", + emitted, config, 0); + if (cmSystemTools::GetErrorOccuredFlag()) { - if (this->Makefile->GetCMakeInstance() - ->GetIsPropertyDefined(pi->c_str(), - cmProperty::TARGET)) - { - cmOStringStream e; - e << "Target \"" << li->Target->GetName() << "\" has property \"" - << *pi << "\" listed in its COMPATIBLE_INTERFACE_BOOL property. " - "This is not allowed. Only user-defined properties may appear " - "listed in the COMPATIBLE_INTERFACE_BOOL property."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); - return; - } - if(emitted.insert(*pi).second) - { - this->GetLinkInterfaceDependentBoolProperty(*pi, config); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - } + return; } } } -- cgit v0.12 From 2fb2c32f9b304bc71b039754f9b9170fd6f27a6f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 6 Jan 2013 13:49:20 +0100 Subject: Add the COMPATIBLE_INTERFACE_STRING property. --- Source/cmExportFileGenerator.cxx | 6 ++ Source/cmGeneratorExpressionEvaluator.cxx | 7 +++ Source/cmTarget.cxx | 65 ++++++++++++++++++++++ Source/cmTarget.h | 5 ++ Tests/CompatibleInterface/CMakeLists.txt | 13 +++++ Tests/CompatibleInterface/main.cpp | 12 ++++ Tests/ExportImport/Export/CMakeLists.txt | 9 ++- Tests/ExportImport/Import/A/CMakeLists.txt | 2 + Tests/ExportImport/Import/A/deps_shared_iface.cpp | 4 ++ .../InterfaceString-builtin-prop-result.txt | 1 + .../InterfaceString-builtin-prop-stderr.txt | 5 ++ .../InterfaceString-builtin-prop.cmake | 11 ++++ ...InterfaceString-mismatch-depend-self-result.txt | 1 + ...InterfaceString-mismatch-depend-self-stderr.txt | 3 + .../InterfaceString-mismatch-depend-self.cmake | 11 ++++ .../InterfaceString-mismatch-depends-result.txt | 1 + .../InterfaceString-mismatch-depends-stderr.txt | 3 + .../InterfaceString-mismatch-depends.cmake | 10 ++++ .../InterfaceString-mismatched-use-result.txt | 1 + .../InterfaceString-mismatched-use-stderr.txt | 4 ++ .../InterfaceString-mismatched-use.cmake | 9 +++ .../CompatibleInterface/RunCMakeTest.cmake | 4 ++ 22 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop-result.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop-stderr.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop.cmake create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depend-self-result.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depend-self-stderr.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depend-self.cmake create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depends-result.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depends-stderr.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depends.cmake create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceString-mismatched-use-result.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceString-mismatched-use-stderr.txt create mode 100644 Tests/RunCMake/CompatibleInterface/InterfaceString-mismatched-use.cmake diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index ef1fc5f..96e0aea 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -217,6 +217,9 @@ void getCompatibleInterfaceProperties(cmTarget *target, getPropertyContents(li->Target, "COMPATIBLE_INTERFACE_BOOL", ifaceProperties); + getPropertyContents(li->Target, + "COMPATIBLE_INTERFACE_STRING", + ifaceProperties); } } @@ -227,10 +230,13 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( { this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_BOOL", target, properties); + this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_STRING", + target, properties); std::set ifaceProperties; getPropertyContents(target, "COMPATIBLE_INTERFACE_BOOL", ifaceProperties); + getPropertyContents(target, "COMPATIBLE_INTERFACE_STRING", ifaceProperties); getCompatibleInterfaceProperties(target, ifaceProperties, 0); diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index c468c39..0c61a12 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -462,6 +462,13 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode propertyName, context->Config) ? "1" : "0"; } + if (target->IsLinkInterfaceDependentStringProperty(propertyName, + context->Config)) + { + return target->GetLinkInterfaceDependentStringProperty( + propertyName, + context->Config); + } return std::string(); } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d2839c5..e3be510 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -908,6 +908,17 @@ void cmTarget::DefineProperties(cmake *cm) "property is not set, then it is ignored."); cm->DefineProperty + ("COMPATIBLE_INTERFACE_STRING", cmProperty::TARGET, + "Properties which must be string-compatible with their link interface", + "The COMPATIBLE_INTERFACE_STRING property may contain a list of " + "properties for this target which must be the same when evaluated as " + "a string in the INTERFACE of all linked dependencies. For example, " + "if a property \"FOO\" appears in the list, then the \"INTERFACE_FOO\" " + "property content in all dependencies must be equal with each " + "other, and with the \"FOO\" property in this target. If the " + "property is not set, then it is ignored."); + + cm->DefineProperty ("POST_INSTALL_SCRIPT", cmProperty::TARGET, "Deprecated install support.", "The PRE_INSTALL_SCRIPT and POST_INSTALL_SCRIPT properties are the " @@ -4512,6 +4523,14 @@ bool getTypedProperty(cmTarget *tgt, const char *prop, bool *) } //---------------------------------------------------------------------------- +template<> +const char *getTypedProperty(cmTarget *tgt, const char *prop, + const char **) +{ + return tgt->GetProperty(prop); +} + +//---------------------------------------------------------------------------- template bool consistentProperty(PropertyType lhs, PropertyType rhs); @@ -4523,6 +4542,17 @@ bool consistentProperty(bool lhs, bool rhs) } //---------------------------------------------------------------------------- +template<> +bool consistentProperty(const char *lhs, const char *rhs) +{ + if (!lhs && !rhs) + return true; + if (!lhs || !rhs) + return false; + return strcmp(lhs, rhs) == 0; +} + +//---------------------------------------------------------------------------- template PropertyType checkInterfacePropertyCompatibility(cmTarget *tgt, const std::string &p, @@ -4668,6 +4698,17 @@ bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, } //---------------------------------------------------------------------------- +const char * cmTarget::GetLinkInterfaceDependentStringProperty( + const std::string &p, + const char *config) +{ + return checkInterfacePropertyCompatibility(this, + p, + config, + "empty", 0); +} + +//---------------------------------------------------------------------------- bool isLinkDependentProperty(cmTarget *tgt, const std::string &p, const char *interfaceProperty, const char *config) @@ -4715,6 +4756,14 @@ bool cmTarget::IsLinkInterfaceDependentBoolProperty(const std::string &p, } //---------------------------------------------------------------------------- +bool cmTarget::IsLinkInterfaceDependentStringProperty(const std::string &p, + const char *config) +{ + return isLinkDependentProperty(this, p, "COMPATIBLE_INTERFACE_STRING", + config); +} + +//---------------------------------------------------------------------------- void cmTarget::GetLanguages(std::set& languages) const { for(std::vector::const_iterator @@ -5468,6 +5517,15 @@ bool getLinkInterfaceDependentProperty(cmTarget *tgt, return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); } +template<> +const char * getLinkInterfaceDependentProperty(cmTarget *tgt, + const std::string prop, + const char *config, + const char **) +{ + return tgt->GetLinkInterfaceDependentStringProperty(prop, config); +} + //---------------------------------------------------------------------------- template void checkPropertyConsistency(cmTarget *depender, cmTarget *dependee, @@ -5536,6 +5594,13 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, { return; } + checkPropertyConsistency(this, li->Target, + "COMPATIBLE_INTERFACE_STRING", + emitted, config, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } } } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 9909bae..4457bec 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -501,12 +501,17 @@ public: bool IsNullImpliedByLinkLibraries(const std::string &p); bool IsLinkInterfaceDependentBoolProperty(const std::string &p, const char *config); + bool IsLinkInterfaceDependentStringProperty(const std::string &p, + const char *config); void AddLinkDependentTargetsForProperties( const std::map &map); bool GetLinkInterfaceDependentBoolProperty(const std::string &p, const char *config); + + const char *GetLinkInterfaceDependentStringProperty(const std::string &p, + const char *config); private: /** * A list of direct dependencies. Use in conjunction with DependencyMap. diff --git a/Tests/CompatibleInterface/CMakeLists.txt b/Tests/CompatibleInterface/CMakeLists.txt index 7280652..259b5a1 100644 --- a/Tests/CompatibleInterface/CMakeLists.txt +++ b/Tests/CompatibleInterface/CMakeLists.txt @@ -14,21 +14,34 @@ set_property(TARGET iface1 APPEND PROPERTY BOOL_PROP3 BOOL_PROP4 ) +set_property(TARGET iface1 APPEND PROPERTY + COMPATIBLE_INTERFACE_STRING + STRING_PROP1 + STRING_PROP2 + STRING_PROP3 +) set_property(TARGET iface1 PROPERTY INTERFACE_BOOL_PROP1 ON) set_property(TARGET iface1 PROPERTY INTERFACE_BOOL_PROP2 ON) +set_property(TARGET iface1 PROPERTY INTERFACE_STRING_PROP1 prop1) +set_property(TARGET iface1 PROPERTY INTERFACE_STRING_PROP2 prop2) add_executable(CompatibleInterface main.cpp) target_link_libraries(CompatibleInterface iface1) set_property(TARGET CompatibleInterface PROPERTY BOOL_PROP2 ON) set_property(TARGET CompatibleInterface PROPERTY BOOL_PROP3 ON) +set_property(TARGET CompatibleInterface PROPERTY STRING_PROP2 prop2) +set_property(TARGET CompatibleInterface PROPERTY STRING_PROP3 prop3) target_compile_definitions(CompatibleInterface PRIVATE $<$>:BOOL_PROP1> $<$>:BOOL_PROP2> $<$>:BOOL_PROP3> + $<$,prop1>:STRING_PROP1> + $<$,prop2>:STRING_PROP2> + $<$,prop3>:STRING_PROP3> ) diff --git a/Tests/CompatibleInterface/main.cpp b/Tests/CompatibleInterface/main.cpp index ae0e985..f5e6e38 100644 --- a/Tests/CompatibleInterface/main.cpp +++ b/Tests/CompatibleInterface/main.cpp @@ -11,6 +11,18 @@ #error Expected BOOL_PROP3 #endif +#ifndef STRING_PROP1 +#error Expected STRING_PROP1 +#endif + +#ifndef STRING_PROP2 +#error Expected STRING_PROP2 +#endif + +#ifndef STRING_PROP3 +#error Expected STRING_PROP3 +#endif + #include "iface2.h" int main(int argc, char **argv) diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index 5992293..eecfd6a 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -181,7 +181,14 @@ set_property(TARGET testSharedLibRequired PROPERTY INTERFACE_CUSTOM_PROP ON ) - +set_property(TARGET testSharedLibRequired + APPEND PROPERTY + COMPATIBLE_INTERFACE_STRING CUSTOM_STRING +) +set_property(TARGET testSharedLibRequired + PROPERTY + INTERFACE_CUSTOM_STRING testcontent +) add_library(testSharedLibDepends SHARED testSharedLibDepends.cpp) set_property(TARGET testSharedLibDepends APPEND PROPERTY diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index 4df5771..187c48a 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -170,6 +170,7 @@ target_compile_definitions(deps_shared_iface testSharedLibDepends $<$>:PIC_PROPERTY_IS_ON> $<$>:CUSTOM_PROPERTY_IS_ON> + $<$,testcontent>:CUSTOM_STRING_IS_MATCH> ) if (APPLE OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") @@ -201,4 +202,5 @@ target_compile_definitions(deps_shared_iface2 PRIVATE bld_testSharedLibDepends TEST_SUBDIR_LIB $<$>:PIC_PROPERTY_IS_ON> $<$>:CUSTOM_PROPERTY_IS_ON> + $<$,testcontent>:CUSTOM_STRING_IS_MATCH> ) diff --git a/Tests/ExportImport/Import/A/deps_shared_iface.cpp b/Tests/ExportImport/Import/A/deps_shared_iface.cpp index a33f200..2f0e74a 100644 --- a/Tests/ExportImport/Import/A/deps_shared_iface.cpp +++ b/Tests/ExportImport/Import/A/deps_shared_iface.cpp @@ -16,6 +16,10 @@ #error Expected CUSTOM_PROPERTY_IS_ON #endif +#ifndef CUSTOM_STRING_IS_MATCH +#error Expected CUSTOM_STRING_IS_MATCH +#endif + #ifdef TEST_SUBDIR_LIB #include "subdir.h" #endif diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop-result.txt b/Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop-stderr.txt b/Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop-stderr.txt new file mode 100644 index 0000000..6a293b4 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop-stderr.txt @@ -0,0 +1,5 @@ +CMake Error in CMakeLists.txt: + Target "foo" has property "INCLUDE_DIRECTORIES" listed in its + COMPATIBLE_INTERFACE_STRING property. This is not allowed. Only + user-defined properties may appear listed in the + COMPATIBLE_INTERFACE_STRING property. diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop.cmake b/Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop.cmake new file mode 100644 index 0000000..5221a12 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-builtin-prop.cmake @@ -0,0 +1,11 @@ + +add_library(foo UNKNOWN IMPORTED) +add_library(bar UNKNOWN IMPORTED) + +set_property(TARGET foo APPEND PROPERTY COMPATIBLE_INTERFACE_STRING INCLUDE_DIRECTORIES) +set_property(TARGET foo PROPERTY INTERFACE_INCLUDE_DIRECTORIES foo_inc) +set_property(TARGET bar PROPERTY INTERFACE_INCLUDE_DIRECTORIES bar_inc) + +add_executable(user main.cpp) +set_property(TARGET user PROPERTY INCLUDE_DIRECTORIES bar_inc) +target_link_libraries(user foo bar) diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depend-self-result.txt b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depend-self-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depend-self-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depend-self-stderr.txt b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depend-self-stderr.txt new file mode 100644 index 0000000..0476da9 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depend-self-stderr.txt @@ -0,0 +1,3 @@ +CMake Error: Property SOMEPROP on target "user" does +not match the INTERFACE_SOMEPROP property requirement +of dependency "foo". diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depend-self.cmake b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depend-self.cmake new file mode 100644 index 0000000..187f29f --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depend-self.cmake @@ -0,0 +1,11 @@ + +add_library(foo UNKNOWN IMPORTED) +add_library(bar UNKNOWN IMPORTED) + +set_property(TARGET foo APPEND PROPERTY COMPATIBLE_INTERFACE_STRING SOMEPROP) +set_property(TARGET foo PROPERTY INTERFACE_SOMEPROP prop) +set_property(TARGET bar PROPERTY INTERFACE_SOMEPROP prop) + +add_executable(user main.cpp) +set_property(TARGET user PROPERTY SOMEPROP different) +target_link_libraries(user foo bar) diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depends-result.txt b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depends-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depends-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depends-stderr.txt b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depends-stderr.txt new file mode 100644 index 0000000..d885c09 --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depends-stderr.txt @@ -0,0 +1,3 @@ +CMake Error: The INTERFACE_SOMEPROP property of "bar" does +not agree with the value of SOMEPROP already determined +for "user". diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depends.cmake b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depends.cmake new file mode 100644 index 0000000..73cc3fc --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatch-depends.cmake @@ -0,0 +1,10 @@ + +add_library(foo UNKNOWN IMPORTED) +add_library(bar UNKNOWN IMPORTED) + +set_property(TARGET foo APPEND PROPERTY COMPATIBLE_INTERFACE_STRING SOMEPROP) +set_property(TARGET foo PROPERTY INTERFACE_SOMEPROP foo) +set_property(TARGET bar PROPERTY INTERFACE_SOMEPROP bar) + +add_executable(user main.cpp) +target_link_libraries(user foo bar) diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatched-use-result.txt b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatched-use-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatched-use-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatched-use-stderr.txt b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatched-use-stderr.txt new file mode 100644 index 0000000..723daec --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatched-use-stderr.txt @@ -0,0 +1,4 @@ +CMake Error: Property SOMEPROP on target "user" is +implied to be empty because it was used to determine the link libraries +already. The INTERFACE_SOMEPROP property on +dependency "foo" is in conflict. diff --git a/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatched-use.cmake b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatched-use.cmake new file mode 100644 index 0000000..af3ce8f --- /dev/null +++ b/Tests/RunCMake/CompatibleInterface/InterfaceString-mismatched-use.cmake @@ -0,0 +1,9 @@ + +add_library(foo UNKNOWN IMPORTED) +add_library(bar UNKNOWN IMPORTED) + +set_property(TARGET foo APPEND PROPERTY COMPATIBLE_INTERFACE_STRING SOMEPROP) +set_property(TARGET foo PROPERTY INTERFACE_SOMEPROP prop) + +add_executable(user main.cpp) +target_link_libraries(user foo $<$,prop>:bar>) diff --git a/Tests/RunCMake/CompatibleInterface/RunCMakeTest.cmake b/Tests/RunCMake/CompatibleInterface/RunCMakeTest.cmake index ba8917b..922ad7f 100644 --- a/Tests/RunCMake/CompatibleInterface/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompatibleInterface/RunCMakeTest.cmake @@ -4,3 +4,7 @@ run_cmake(InterfaceBool-mismatch-depends) run_cmake(InterfaceBool-mismatch-depend-self) run_cmake(InterfaceBool-mismatched-use) run_cmake(InterfaceBool-builtin-prop) +run_cmake(InterfaceString-mismatch-depends) +run_cmake(InterfaceString-mismatch-depend-self) +run_cmake(InterfaceString-mismatched-use) +run_cmake(InterfaceString-builtin-prop) -- cgit v0.12 From d4774140b7fa8685a9f29147308fd7fe5365e1fb Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Thu, 24 Jan 2013 21:15:58 +0100 Subject: configure_package_config_file: force absolute paths for usr-move The configure_package_config()_file() macro will now use absolute paths for the PATH_VARS if the Config.cmake file will be installed into /lib(64) or /usr/lib(64), since due to the usr-move filesystem changes Config.cmake files installed there may be found via two paths (once per symlink via /lib(64) and once via /usr/lib ), and in this case relative paths break. Alex --- Modules/CMakePackageConfigHelpers.cmake | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Modules/CMakePackageConfigHelpers.cmake b/Modules/CMakePackageConfigHelpers.cmake index a92ce7c..13617ce 100644 --- a/Modules/CMakePackageConfigHelpers.cmake +++ b/Modules/CMakePackageConfigHelpers.cmake @@ -173,18 +173,34 @@ function(CONFIGURE_PACKAGE_CONFIG_FILE _inputFile _outputFile) else() set(absInstallDir "${CMAKE_INSTALL_PREFIX}/${CCF_INSTALL_DESTINATION}") endif() + + # with the /usr-move, /lib(64) is a symlink to /usr/lib on Fedora, ArchLinux, Mageira and others. + # If we are installed to such a location, force using absolute paths. + set(forceAbsolutePaths FALSE) + if("${absInstallDir}" MATCHES "^(/usr)?/lib(64)?/.+") + set(forceAbsolutePaths TRUE) + endif() + file(RELATIVE_PATH PACKAGE_RELATIVE_PATH "${absInstallDir}" "${CMAKE_INSTALL_PREFIX}" ) foreach(var ${CCF_PATH_VARS}) if(NOT DEFINED ${var}) message(FATAL_ERROR "Variable ${var} does not exist") else() + if(forceAbsolutePaths) + if(IS_ABSOLUTE "${${var}}") + set(PACKAGE_${var} "${${var}}") + else() + set(PACKAGE_${var} "${CMAKE_INSTALL_PREFIX}/${${var}}") + endif() + else() if(IS_ABSOLUTE "${${var}}") string(REPLACE "${CMAKE_INSTALL_PREFIX}" "\${PACKAGE_PREFIX_DIR}" PACKAGE_${var} "${${var}}") else() set(PACKAGE_${var} "\${PACKAGE_PREFIX_DIR}/${${var}}") endif() + endif() endif() endforeach() -- cgit v0.12 From 37c4bc1f86a72a76a1ccc3094ba7cc3ec134ff21 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Thu, 24 Jan 2013 21:18:47 +0100 Subject: configure_package_config_file(): fix indentation This is a separate commit, so that the previous commit is smaller. Alex --- Modules/CMakePackageConfigHelpers.cmake | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Modules/CMakePackageConfigHelpers.cmake b/Modules/CMakePackageConfigHelpers.cmake index 13617ce..d6d3cb1 100644 --- a/Modules/CMakePackageConfigHelpers.cmake +++ b/Modules/CMakePackageConfigHelpers.cmake @@ -194,12 +194,12 @@ function(CONFIGURE_PACKAGE_CONFIG_FILE _inputFile _outputFile) set(PACKAGE_${var} "${CMAKE_INSTALL_PREFIX}/${${var}}") endif() else() - if(IS_ABSOLUTE "${${var}}") - string(REPLACE "${CMAKE_INSTALL_PREFIX}" "\${PACKAGE_PREFIX_DIR}" - PACKAGE_${var} "${${var}}") - else() - set(PACKAGE_${var} "\${PACKAGE_PREFIX_DIR}/${${var}}") - endif() + if(IS_ABSOLUTE "${${var}}") + string(REPLACE "${CMAKE_INSTALL_PREFIX}" "\${PACKAGE_PREFIX_DIR}" + PACKAGE_${var} "${${var}}") + else() + set(PACKAGE_${var} "\${PACKAGE_PREFIX_DIR}/${${var}}") + endif() endif() endif() endforeach() -- cgit v0.12 From 4cad84836989c6c9e4da97fced637b7bdbc222c7 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Thu, 24 Jan 2013 21:27:32 +0100 Subject: configure_package_config_file(): extend documentation Alex --- Modules/CMakePackageConfigHelpers.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/CMakePackageConfigHelpers.cmake b/Modules/CMakePackageConfigHelpers.cmake index d6d3cb1..393d05c 100644 --- a/Modules/CMakePackageConfigHelpers.cmake +++ b/Modules/CMakePackageConfigHelpers.cmake @@ -9,6 +9,8 @@ # configure_file() command when creating the Config.cmake or -config.cmake # file for installing a project or library. It helps making the resulting package # relocatable by avoiding hardcoded paths in the installed Config.cmake file. +# Config.cmake files installed under UNIX into /lib(64) or /usr/lib(64) are +# considered system packages and are not relocatable. # # In a FooConfig.cmake file there may be code like this to make the # install destinations know to the using project: -- cgit v0.12 From f032fb904b9b7a4f18702bcdbdeff0dfda01b803 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 24 Jan 2013 15:46:22 -0500 Subject: target_link_libraries: Document that new sigs privatize old (#13876) Explain in the documentation for the legacy signature target_link_libraries(foo bar) that the other signatures like target_link_libraries(foo LINK_INTERFACE_LIBRARIES ...) target_link_libraries(foo LINK_PRIVATE ...) will set the LINK_INTERFACE_LIBRARIES target property and therefore make libraries specified only by the legacy signature private. --- Source/cmTargetLinkLibrariesCommand.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/cmTargetLinkLibrariesCommand.h b/Source/cmTargetLinkLibrariesCommand.h index 34fe54c..3da3950 100644 --- a/Source/cmTargetLinkLibrariesCommand.h +++ b/Source/cmTargetLinkLibrariesCommand.h @@ -93,7 +93,9 @@ public: "linked to this target will appear on the link line for the other " "target too. " "See the LINK_INTERFACE_LIBRARIES target property to override the " - "set of transitive link dependencies for a target." + "set of transitive link dependencies for a target. " + "Calls to other signatures of this command may set the property " + "making any libraries linked exclusively by this signature private." "\n" " target_link_libraries( LINK_INTERFACE_LIBRARIES\n" " [[debug|optimized|general] ] ...)\n" -- cgit v0.12 From 6c57c31414b17028cfe2c393752458d5899f09a4 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Thu, 24 Jan 2013 22:04:09 +0100 Subject: doc: fix linebreaks in generator expression documentation --- Source/cmDocumentGeneratorExpressions.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/cmDocumentGeneratorExpressions.h b/Source/cmDocumentGeneratorExpressions.h index c2bf423..be9f2ff 100644 --- a/Source/cmDocumentGeneratorExpressions.h +++ b/Source/cmDocumentGeneratorExpressions.h @@ -47,9 +47,10 @@ " $/$\n" \ " $/$\n" \ "\n" \ - " $ = The value of the property prop\n" \ - "on the target tgt. Note that tgt is not added as a dependency of\n" \ - "the target this expression is evaluated on.\n" \ + " $ = The value of the property prop " \ + "on the target tgt.\n" \ + "Note that tgt is not added as a dependency of the target this " \ + "expression is evaluated on.\n" \ " $ = '1' if the policy was NEW when " \ "the 'head' target was created, else '0'. If the policy was not " \ "set, the warning message for the policy will be emitted. This " \ @@ -64,7 +65,7 @@ #define CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS \ CM_DOCUMENT_ADD_TEST_GENERATOR_EXPRESSIONS \ "Expressions with an implicit 'this' target:\n" \ - " $ = The value of the property prop on\n" \ + " $ = The value of the property prop on " \ "the target on which the generator expression is evaluated.\n" \ "" -- cgit v0.12 From e03f83f394c53acbcc9dcff03f189170b2f33322 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Thu, 24 Jan 2013 23:15:13 +0100 Subject: ProcessorCount test: fix path to cmsysTestsCxx executable Use a generator expression to get the real place of this target instead of guessing it wrong. --- Tests/CMakeTests/CMakeLists.txt | 5 +++-- Tests/CMakeTests/ProcessorCountTest.cmake.in | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt index d34d4a6..b049995 100644 --- a/Tests/CMakeTests/CMakeLists.txt +++ b/Tests/CMakeTests/CMakeLists.txt @@ -4,7 +4,8 @@ set(CMAKE_EXECUTABLE "${CMake_BIN_DIR}/cmake") macro(AddCMakeTest TestName PreArgs) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${TestName}Test.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/${TestName}Test.cmake" @ONLY IMMEDIATE) - add_test(CMake.${TestName} ${CMAKE_EXECUTABLE} ${PreArgs} + add_test(NAME CMake.${TestName} + COMMAND ${CMAKE_EXECUTABLE} ${PreArgs} -P "${CMAKE_CURRENT_BINARY_DIR}/${TestName}Test.cmake" ${ARGN}) endmacro() @@ -28,7 +29,7 @@ AddCMakeTest(String "") AddCMakeTest(Math "") AddCMakeTest(CMakeMinimumRequired "") AddCMakeTest(CompilerIdVendor "") -AddCMakeTest(ProcessorCount "") +AddCMakeTest(ProcessorCount "-DKWSYS_TEST_EXE=$") AddCMakeTest(PushCheckState "") AddCMakeTest(While "") diff --git a/Tests/CMakeTests/ProcessorCountTest.cmake.in b/Tests/CMakeTests/ProcessorCountTest.cmake.in index 98f6ab1..15e0219 100644 --- a/Tests/CMakeTests/ProcessorCountTest.cmake.in +++ b/Tests/CMakeTests/ProcessorCountTest.cmake.in @@ -9,7 +9,7 @@ message("### 3. ProcessorCount(...) function call is emitting output that it sho message("processor_count='${processor_count}'") execute_process( - COMMAND "@CMAKE_BINARY_DIR@/Source/kwsys/$ENV{CMAKE_CONFIG_TYPE}/cmsysTestsCxx" + COMMAND "${KWSYS_TEST_EXE}" testSystemInformation OUTPUT_VARIABLE tsi_out ERROR_VARIABLE tsi_err) -- cgit v0.12 From 4d0e2e81e9c60f6f147f3b332b1d885d543b2084 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Wed, 23 Jan 2013 20:23:18 +0100 Subject: ProcessorCount test: require SystemInformation process to work Currently this silently fails on some systems. Make sure those things get noticed so we can fix that. --- Tests/CMakeTests/ProcessorCountTest.cmake.in | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Tests/CMakeTests/ProcessorCountTest.cmake.in b/Tests/CMakeTests/ProcessorCountTest.cmake.in index 15e0219..f92dcc4 100644 --- a/Tests/CMakeTests/ProcessorCountTest.cmake.in +++ b/Tests/CMakeTests/ProcessorCountTest.cmake.in @@ -12,7 +12,14 @@ execute_process( COMMAND "${KWSYS_TEST_EXE}" testSystemInformation OUTPUT_VARIABLE tsi_out - ERROR_VARIABLE tsi_err) + ERROR_VARIABLE tsi_err + RESULT_VARIABLE tsi_res +) +if (tsi_res) + message("executing \"${KWSYS_TEST_EXE}\" failed") + message(FATAL_ERROR "output: ${tsi_res}") +endif () + string(REGEX REPLACE "(.*)GetNumberOfPhysicalCPU:.([0-9]*)(.*)" "\\2" system_info_processor_count "${tsi_out}") -- cgit v0.12 From a4eb27fbab81087fde72f2058b60a67f1f9298da Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Fri, 25 Jan 2013 00:01:19 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 2c688b7..2c52111 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130124) +set(CMake_VERSION_TWEAK 20130125) #set(CMake_VERSION_RC 1) -- cgit v0.12 From f7db6d115d0bd665ee0ed9be9994a59792d016af Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sat, 26 Jan 2013 00:01:18 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 2c52111..059bb6c 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130125) +set(CMake_VERSION_TWEAK 20130126) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 00ba2545fabcb8ce7d62387464060634683282b9 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sun, 27 Jan 2013 00:01:25 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 059bb6c..380f6cd 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130126) +set(CMake_VERSION_TWEAK 20130127) #set(CMake_VERSION_RC 1) -- cgit v0.12 From e2afc40d0651e3762829fa911bfc11373afd092b Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Mon, 28 Jan 2013 00:01:18 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 380f6cd..ef3952b 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130127) +set(CMake_VERSION_TWEAK 20130128) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 61d641dccb216bd585430231e0851c6b6eab4343 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Tue, 29 Jan 2013 00:01:18 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index ef3952b..608c269 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 10) -set(CMake_VERSION_TWEAK 20130128) +set(CMake_VERSION_TWEAK 20130129) #set(CMake_VERSION_RC 1) -- cgit v0.12 From 0e10782ba795050e1ea82530d79c323f60478df4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 26 Dec 2012 03:40:49 +0100 Subject: Move GetCompileDefinitions to cmTarget. --- Source/cmExtraCodeBlocksGenerator.cxx | 2 +- Source/cmGeneratorTarget.cxx | 29 ----------------------------- Source/cmGeneratorTarget.h | 2 -- Source/cmGlobalXCodeGenerator.cxx | 4 ++-- Source/cmLocalVisualStudio6Generator.cxx | 14 +++++--------- Source/cmLocalVisualStudio7Generator.cxx | 4 ++-- Source/cmMakefileTargetGenerator.cxx | 4 ++-- Source/cmNinjaTargetGenerator.cxx | 4 ++-- Source/cmTarget.cxx | 29 +++++++++++++++++++++++++++++ Source/cmTarget.h | 2 ++ Source/cmVisualStudio10TargetGenerator.cxx | 4 ++-- 11 files changed, 47 insertions(+), 51 deletions(-) diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 0cf9cbb..6d5d5b5 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -621,7 +621,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, ->GetGeneratorTarget(target); // the compilerdefines for this target - std::string cdefs = gtgt->GetCompileDefinitions(); + std::string cdefs = target->GetCompileDefinitions(); if(!cdefs.empty()) { diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 62ee26a..335ba0f 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -254,32 +254,3 @@ std::vector cmGeneratorTarget::GetIncludeDirectories( { return this->Target->GetIncludeDirectories(config); } - -//---------------------------------------------------------------------------- -std::string cmGeneratorTarget::GetCompileDefinitions(const char *config) -{ - std::string defPropName = "COMPILE_DEFINITIONS"; - if (config) - { - defPropName += "_" + cmSystemTools::UpperCase(config); - } - - const char *prop = this->Target->GetProperty(defPropName.c_str()); - - if (!prop) - { - return ""; - } - - cmListFileBacktrace lfbt; - cmGeneratorExpression ge(lfbt); - - cmGeneratorExpressionDAGChecker dagChecker(lfbt, - this->GetName(), - defPropName, 0, 0); - return ge.Parse(prop)->Evaluate(this->Makefile, - config, - false, - this->Target, - &dagChecker); -} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 6f5ecb7..cbcd8a5 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -68,8 +68,6 @@ public: /** Get the include directories for this target. */ std::vector GetIncludeDirectories(const char *config); - std::string GetCompileDefinitions(const char *config = 0); - private: void ClassifySources(); void LookupObjectLibraries(); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 0681ce5..abe60c6 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1681,11 +1681,11 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->AppendDefines(ppDefs, exportMacro); } cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); - this->AppendDefines(ppDefs, gtgt->GetCompileDefinitions().c_str()); + this->AppendDefines(ppDefs, target.GetCompileDefinitions().c_str()); if(configName) { this->AppendDefines(ppDefs, - gtgt->GetCompileDefinitions(configName).c_str()); + target.GetCompileDefinitions(configName).c_str()); } buildSettings->AddAttribute ("GCC_PREPROCESSOR_DEFINITIONS", ppDefs.CreateList()); diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 6c78ac4..617eb4e 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1697,25 +1697,21 @@ void cmLocalVisualStudio6Generator std::set minsizeDefinesSet; std::set debugrelDefinesSet; - - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(&target); - this->AppendDefines( definesSet, - gt->GetCompileDefinitions()); + target.GetCompileDefinitions()); this->AppendDefines( debugDefinesSet, - gt->GetCompileDefinitions("DEBUG")); + target.GetCompileDefinitions("DEBUG")); this->AppendDefines( releaseDefinesSet, - gt->GetCompileDefinitions("RELEASE")); + target.GetCompileDefinitions("RELEASE")); this->AppendDefines( minsizeDefinesSet, - gt->GetCompileDefinitions("MINSIZEREL")); + target.GetCompileDefinitions("MINSIZEREL")); this->AppendDefines( debugrelDefinesSet, - gt->GetCompileDefinitions("RELWITHDEBINFO")); + target.GetCompileDefinitions("RELWITHDEBINFO")); std::string defines = " "; std::string debugDefines = " "; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 918b21e..f9df861 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -745,8 +745,8 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, targetOptions.ParseFinish(); cmGeneratorTarget* gt = this->GlobalGenerator->GetGeneratorTarget(&target); - targetOptions.AddDefines(gt->GetCompileDefinitions().c_str()); - targetOptions.AddDefines(gt->GetCompileDefinitions(configName).c_str()); + targetOptions.AddDefines(target.GetCompileDefinitions().c_str()); + targetOptions.AddDefines(target.GetCompileDefinitions(configName).c_str()); targetOptions.SetVerboseMakefile( this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 64fcfce..d9aa7fe 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -303,10 +303,10 @@ std::string cmMakefileTargetGenerator::GetDefines(const std::string &l) // Add preprocessor definitions for this target and configuration. this->LocalGenerator->AppendDefines - (defines, this->GeneratorTarget->GetCompileDefinitions()); + (defines, this->Target->GetCompileDefinitions()); this->LocalGenerator->AppendDefines - (defines, this->GeneratorTarget->GetCompileDefinitions( + (defines, this->Target->GetCompileDefinitions( this->LocalGenerator->ConfigurationName.c_str())); std::string definesString; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 0f484da..f8e4399 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -228,7 +228,7 @@ ComputeDefines(cmSourceFile *source, const std::string& language) // Add preprocessor definitions for this target and configuration. this->LocalGenerator->AppendDefines (defines, - this->GeneratorTarget->GetCompileDefinitions()); + this->Target->GetCompileDefinitions()); this->LocalGenerator->AppendDefines (defines, source->GetProperty("COMPILE_DEFINITIONS")); @@ -237,7 +237,7 @@ ComputeDefines(cmSourceFile *source, const std::string& language) defPropName += cmSystemTools::UpperCase(this->GetConfigName()); this->LocalGenerator->AppendDefines (defines, - this->GeneratorTarget->GetCompileDefinitions(this->GetConfigName())); + this->Target->GetCompileDefinitions(this->GetConfigName())); this->LocalGenerator->AppendDefines (defines, source->GetProperty(defPropName.c_str())); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 2b912f3..9fd2d13 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2804,6 +2804,35 @@ std::vector cmTarget::GetIncludeDirectories(const char *config) } //---------------------------------------------------------------------------- +std::string cmTarget::GetCompileDefinitions(const char *config) +{ + std::string defPropName = "COMPILE_DEFINITIONS"; + if (config) + { + defPropName += "_" + cmSystemTools::UpperCase(config); + } + + const char *prop = this->GetProperty(defPropName.c_str()); + + if (!prop) + { + return ""; + } + + cmListFileBacktrace lfbt; + cmGeneratorExpression ge(lfbt); + + cmGeneratorExpressionDAGChecker dagChecker(lfbt, + this->GetName(), + defPropName, 0, 0); + return ge.Parse(prop)->Evaluate(this->Makefile, + config, + false, + this, + &dagChecker); +} + +//---------------------------------------------------------------------------- void cmTarget::MaybeInvalidatePropertyCache(const char* prop) { // Wipe out maps caching information affected by this property. diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 9909bae..11dfdf7 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -430,6 +430,8 @@ public: If no macro should be defined null is returned. */ const char* GetExportMacro(); + std::string GetCompileDefinitions(const char *config = 0); + // Compute the set of languages compiled by the target. This is // computed every time it is called because the languages can change // when source file properties are changed and we do not have enough diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 2596d73..171ed9a 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1221,8 +1221,8 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( clOptions.Parse(flags.c_str()); clOptions.Parse(defineFlags.c_str()); clOptions.AddDefines( - this->GeneratorTarget->GetCompileDefinitions().c_str()); - clOptions.AddDefines(this->GeneratorTarget->GetCompileDefinitions( + this->Target->GetCompileDefinitions().c_str()); + clOptions.AddDefines(this->Target->GetCompileDefinitions( configName.c_str()).c_str()); clOptions.SetVerboseMakefile( this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")); -- cgit v0.12 From 429e369974015640d7a0878d986e3e418b42b7a4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 25 Jan 2013 14:03:17 +0100 Subject: Process COMPILE_DEFINITIONS as generator expressions in QtAutomoc. Fixes #13493. --- Source/cmQtAutomoc.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index bf034cf..cc42175 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -229,7 +229,11 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) } const char* tmp = target->GetProperty("COMPILE_DEFINITIONS"); - std::string _moc_compile_defs = (tmp!=0 ? tmp : ""); + std::string _moc_compile_defs; + if (tmp) + { + _moc_compile_defs = target->GetCompileDefinitions(); + } tmp = makefile->GetProperty("COMPILE_DEFINITIONS"); if (tmp) { -- cgit v0.12