From b030323c133155c57437527d04ca2ba619663f6d Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 12 Feb 2013 10:38:45 +0100 Subject: [PATCH 01/10] Fix determination of when we're evaluating compile definitions. Also handle the config-specific property. --- Source/cmGeneratorExpressionDAGChecker.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index 0ac1a483d..57e7358b5 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -165,5 +165,6 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingCompileDefinitions() { const char *prop = this->Property.c_str(); return (strcmp(prop, "COMPILE_DEFINITIONS") == 0 - || strcmp(prop, "INTERFACE_COMPILE_DEFINITIONS") == 0 ); + || strcmp(prop, "INTERFACE_COMPILE_DEFINITIONS") == 0 + || strncmp(prop, "COMPILE_DEFINITIONS_", 20) == 0); } From 5b88504f650c7bcd3d404853b26292b50fa6f141 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 12 Feb 2013 10:35:28 +0100 Subject: [PATCH 02/10] Rename the IncludeDirectoriesEntry to be more generic. --- Source/cmListFileCache.h | 9 +++++++ Source/cmMakefile.cxx | 12 ++++----- Source/cmMakefile.h | 7 ++--- Source/cmMakefileIncludeDirectoriesEntry.h | 28 -------------------- Source/cmTarget.cxx | 6 ++--- Source/cmTarget.h | 4 +-- Source/cmTargetCompileDefinitionsCommand.cxx | 2 -- Source/cmTargetIncludeDirectoriesCommand.cxx | 4 +-- 8 files changed, 23 insertions(+), 49 deletions(-) delete mode 100644 Source/cmMakefileIncludeDirectoriesEntry.h diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h index c057754a3..fec3d07d8 100644 --- a/Source/cmListFileCache.h +++ b/Source/cmListFileCache.h @@ -76,4 +76,13 @@ struct cmListFile std::vector Functions; }; +struct cmValueWithOrigin { + cmValueWithOrigin(const std::string &value, + const cmListFileBacktrace &bt) + : Value(value), Backtrace(bt) + {} + std::string Value; + cmListFileBacktrace Backtrace; +}; + #endif diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 299e5646f..25ccbc739 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1487,7 +1487,7 @@ void cmMakefile::InitializeFromParent() // Initialize definitions with the closure of the parent scope. this->Internal->VarStack.top() = parent->Internal->VarStack.top().Closure(); - const std::vector parentIncludes = + const std::vector parentIncludes = parent->GetIncludeDirectoriesEntries(); this->IncludeDirectoriesEntries.insert(this->IncludeDirectoriesEntries.end(), parentIncludes.begin(), @@ -1636,13 +1636,13 @@ void cmMakefile::AddIncludeDirectories(const std::vector &incs, sep = ";"; } - std::vector::iterator position = + std::vector::iterator position = before ? this->IncludeDirectoriesEntries.begin() : this->IncludeDirectoriesEntries.end(); cmListFileBacktrace lfbt; this->GetBacktrace(lfbt); - IncludeDirectoriesEntry entry(incString, lfbt); + cmValueWithOrigin entry(incString, lfbt); this->IncludeDirectoriesEntries.insert(position, entry); // Property on each target: @@ -3461,7 +3461,7 @@ void cmMakefile::SetProperty(const char* prop, const char* value) cmListFileBacktrace lfbt; this->GetBacktrace(lfbt); this->IncludeDirectoriesEntries.push_back( - IncludeDirectoriesEntry(value, lfbt)); + cmValueWithOrigin(value, lfbt)); return; } @@ -3500,7 +3500,7 @@ void cmMakefile::AppendProperty(const char* prop, const char* value, cmListFileBacktrace lfbt; this->GetBacktrace(lfbt); this->IncludeDirectoriesEntries.push_back( - IncludeDirectoriesEntry(value, lfbt)); + cmValueWithOrigin(value, lfbt)); return; } if ( propname == "LINK_DIRECTORIES" ) @@ -3617,7 +3617,7 @@ const char *cmMakefile::GetProperty(const char* prop, else if (!strcmp("INCLUDE_DIRECTORIES",prop)) { std::string sep; - for (std::vector::const_iterator + for (std::vector::const_iterator it = this->IncludeDirectoriesEntries.begin(), end = this->IncludeDirectoriesEntries.end(); it != end; ++it) diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index c0020bf6b..74a731d5b 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -22,7 +22,6 @@ #include "cmNewLineStyle.h" #include "cmGeneratorTarget.h" #include "cmake.h" -#include "cmMakefileIncludeDirectoriesEntry.h" #if defined(CMAKE_BUILD_WITH_CMAKE) #include "cmSourceGroup.h" @@ -863,9 +862,7 @@ public: /** Set whether or not to report a CMP0000 violation. */ void SetCheckCMP0000(bool b) { this->CheckCMP0000 = b; } - typedef cmMakefileIncludeDirectoriesEntry IncludeDirectoriesEntry; - - std::vector GetIncludeDirectoriesEntries() const + std::vector GetIncludeDirectoriesEntries() const { return this->IncludeDirectoriesEntries; } @@ -921,7 +918,7 @@ protected: std::vector HeaderFileExtensions; std::string DefineFlags; - std::vector IncludeDirectoriesEntries; + std::vector IncludeDirectoriesEntries; // Track the value of the computed DEFINITIONS property. void AddDefineFlag(const char*, std::string&); diff --git a/Source/cmMakefileIncludeDirectoriesEntry.h b/Source/cmMakefileIncludeDirectoriesEntry.h deleted file mode 100644 index f35642dfb..000000000 --- a/Source/cmMakefileIncludeDirectoriesEntry.h +++ /dev/null @@ -1,28 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2012 Stephen Kelly - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ - -#ifndef cmMakefileIncludeDirectoriesEntry_h -#define cmMakefileIncludeDirectoriesEntry_h - -#include -#include "cmListFileCache.h" - -struct cmMakefileIncludeDirectoriesEntry { - cmMakefileIncludeDirectoriesEntry(const std::string &value, - const cmListFileBacktrace &bt) - : Value(value), Backtrace(bt) - {} - std::string Value; - cmListFileBacktrace Backtrace; -}; - -#endif diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index bf918d52e..6da6957c2 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1496,10 +1496,10 @@ void cmTarget::SetMakefile(cmMakefile* mf) // Initialize the INCLUDE_DIRECTORIES property based on the current value // of the same directory property: - const std::vector parentIncludes = + const std::vector parentIncludes = this->Makefile->GetIncludeDirectoriesEntries(); - for (std::vector::const_iterator it + for (std::vector::const_iterator it = parentIncludes.begin(); it != parentIncludes.end(); ++it) { this->InsertInclude(*it); @@ -2743,7 +2743,7 @@ void cmTarget::AppendBuildInterfaceIncludes() } //---------------------------------------------------------------------------- -void cmTarget::InsertInclude(const cmMakefileIncludeDirectoriesEntry &entry, +void cmTarget::InsertInclude(const cmValueWithOrigin &entry, bool before) { cmGeneratorExpression ge(entry.Backtrace); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index fb1496fa2..028a55e53 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -15,7 +15,7 @@ #include "cmCustomCommand.h" #include "cmPropertyMap.h" #include "cmPolicies.h" -#include "cmMakefileIncludeDirectoriesEntry.h" +#include "cmListFileCache.h" #include @@ -493,7 +493,7 @@ public: std::string GetFrameworkDirectory(const char* config = 0); std::vector GetIncludeDirectories(const char *config); - void InsertInclude(const cmMakefileIncludeDirectoriesEntry &entry, + void InsertInclude(const cmValueWithOrigin &entry, bool before = false); void AppendBuildInterfaceIncludes(); diff --git a/Source/cmTargetCompileDefinitionsCommand.cxx b/Source/cmTargetCompileDefinitionsCommand.cxx index 76458338c..ba0ad5986 100644 --- a/Source/cmTargetCompileDefinitionsCommand.cxx +++ b/Source/cmTargetCompileDefinitionsCommand.cxx @@ -11,8 +11,6 @@ ============================================================================*/ #include "cmTargetCompileDefinitionsCommand.h" -#include "cmMakefileIncludeDirectoriesEntry.h" - bool cmTargetCompileDefinitionsCommand ::InitialPass(std::vector const& args, cmExecutionStatus &) { diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx index 808806a3a..12d0a515f 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.cxx +++ b/Source/cmTargetIncludeDirectoriesCommand.cxx @@ -11,8 +11,6 @@ ============================================================================*/ #include "cmTargetIncludeDirectoriesCommand.h" -#include "cmMakefileIncludeDirectoriesEntry.h" - //---------------------------------------------------------------------------- bool cmTargetIncludeDirectoriesCommand ::InitialPass(std::vector const& args, cmExecutionStatus &) @@ -71,6 +69,6 @@ void cmTargetIncludeDirectoriesCommand { cmListFileBacktrace lfbt; this->Makefile->GetBacktrace(lfbt); - cmMakefileIncludeDirectoriesEntry entry(this->Join(content), lfbt); + cmValueWithOrigin entry(this->Join(content), lfbt); tgt->InsertInclude(entry, prepend); } From 5c9f5e313ff893a28f975749ad9a6b19481e8e62 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 12 Feb 2013 10:37:37 +0100 Subject: [PATCH 03/10] Don't use LINKED where not needed. --- Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt | 2 +- Tests/CMakeCommands/target_include_directories/CMakeLists.txt | 2 +- .../IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt index 0bfcc1b1b..8fed4ca48 100644 --- a/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt +++ b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt @@ -25,6 +25,6 @@ target_compile_definitions(consumer PRIVATE $ $<$:SHOULD_NOT_BE_DEFINED> $<$:SHOULD_BE_DEFINED> - $ + $ -DDASH_D_DEFINE ) diff --git a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt index a56491807..2c2ca42a6 100644 --- a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt +++ b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt @@ -52,6 +52,6 @@ set_property(TARGET linked PROPERTY target_include_directories(consumer PRIVATE $ - $ + $ relative_dir ) diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt index 538737732..ad6671feb 100644 --- a/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt @@ -121,5 +121,5 @@ target_link_libraries(lib5 libbad libgood) # get the libgood includes in before the libbad includes. # We do that with this command: target_include_directories(lib5 - BEFORE PRIVATE $ + BEFORE PRIVATE $ ) From a1c4905f723f9d99bd481580f9fe24fdaf81b174 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 12 Feb 2013 11:29:09 +0100 Subject: [PATCH 04/10] Use the link information as a source of compile definitions and includes. After evaluating the INTERFACE_INCLUDE_DIRECTORIES, of a target in a generator expression, also read the INTERFACE_INCLUDE_DIRECTORIES of its link interface dependencies. That means that code such as this will result in the 'user' target using /bar/include and /foo/include: add_library(foo ...) target_include_directories(foo INTERFACE /foo/include) add_library(bar ...) target_include_directories(bar INTERFACE /bar/include) target_link_libraries(bar LINK_PUBLIC foo) add_executable(user ...) target_include_directories(user PRIVATE $) Also process the interface include directories from direct link dependencies for in-build targets. The situation is similar for the INTERFACE_COMPILE_DEFINITIONS. The include directories related code is currently more complex because we also need to store a backtrace at configure-time for the purpose of debugging includes. The compile definitions related code will use the same pattern in the future. This is not a change in behavior, as existing code has the same effect, but that existing code will be removed in follow-up commits. --- Source/cmGeneratorExpressionEvaluator.cxx | 69 ++++++- Source/cmTarget.cxx | 223 +++++++++++++++------- Source/cmTarget.h | 1 + Source/cmTargetLinkLibrariesCommand.cxx | 8 + 4 files changed, 231 insertions(+), 70 deletions(-) diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 98e0ada67..6c1c12a32 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -451,15 +451,68 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } const char *prop = target->GetProperty(propertyName.c_str()); + + std::string linkedTargetsContent; + + if (dagCheckerParent) + { + if (dagCheckerParent->EvaluatingLinkLibraries()) + { + if(!prop) + { + return std::string(); + } + } + else + { + assert(dagCheckerParent->EvaluatingIncludeDirectories() + || dagCheckerParent->EvaluatingCompileDefinitions()); + + if (propertyName == "INTERFACE_INCLUDE_DIRECTORIES" + || propertyName == "INTERFACE_COMPILE_DEFINITIONS") + { + const cmTarget::LinkInterface *iface = target->GetLinkInterface( + context->Config, + context->HeadTarget); + if(iface) + { + cmGeneratorExpression ge(context->Backtrace); + + std::string sep; + std::string depString; + for (std::vector::const_iterator + it = iface->Libraries.begin(); + it != iface->Libraries.end(); ++it) + { + if (context->Makefile->FindTargetToUse(it->c_str())) + { + depString += + sep + "$"; + sep = ";"; + } + } + cmsys::auto_ptr cge = + ge.Parse(depString); + linkedTargetsContent = cge->Evaluate(context->Makefile, + context->Config, + context->Quiet, + context->HeadTarget, + target, + &dagChecker); + if (cge->GetHadContextSensitiveCondition()) + { + context->HadContextSensitiveCondition = true; + } + } + } + } + } + if (!prop) { if (target->IsImported()) { - return std::string(); - } - if (dagCheckerParent && dagCheckerParent->EvaluatingLinkLibraries()) - { - return std::string(); + return linkedTargetsContent; } if (target->IsLinkInterfaceDependentBoolProperty(propertyName, context->Config)) @@ -480,7 +533,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode return propContent ? propContent : ""; } - return std::string(); + return linkedTargetsContent; } for (size_t i = 0; @@ -503,6 +556,10 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; } + if (!linkedTargetsContent.empty()) + { + result += (result.empty() ? "" : ";") + linkedTargetsContent; + } return result; } } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 6da6957c2..003f3d830 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -137,6 +137,7 @@ public: std::vector CachedIncludes; }; std::vector IncludeDirectoriesEntries; + std::vector LinkInterfaceIncludeDirectoriesEntries; }; //---------------------------------------------------------------------------- @@ -2742,6 +2743,12 @@ void cmTarget::AppendBuildInterfaceIncludes() } } +//---------------------------------------------------------------------------- +void cmTarget::AppendTllInclude(const cmValueWithOrigin &entry) +{ + this->Internal->LinkInterfaceIncludeDirectoriesEntries.push_back(entry); +} + //---------------------------------------------------------------------------- void cmTarget::InsertInclude(const cmValueWithOrigin &entry, bool before) @@ -2756,6 +2763,73 @@ void cmTarget::InsertInclude(const cmValueWithOrigin &entry, new cmTargetInternals::IncludeDirectoriesEntry(ge.Parse(entry.Value))); } +//---------------------------------------------------------------------------- +static void processIncludeDirectories(cmTarget *tgt, + const std::vector &entries, + std::vector &includes, + std::set &uniqueIncludes, + cmGeneratorExpressionDAGChecker *dagChecker, + const char *config, bool debugIncludes) +{ + cmMakefile *mf = tgt->GetMakefile(); + + for (std::vector::const_iterator + it = entries.begin(), end = entries.end(); it != end; ++it) + { + bool testIsOff = true; + bool cacheIncludes = false; + std::vector entryIncludes = (*it)->CachedIncludes; + if(!entryIncludes.empty()) + { + testIsOff = false; + } + else + { + cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, + config, + false, + tgt, + dagChecker), + entryIncludes); + if (mf->IsGeneratingBuildSystem() + && !(*it)->ge->GetHadContextSensitiveCondition()) + { + cacheIncludes = true; + } + } + std::string usedIncludes; + for(std::vector::iterator + li = entryIncludes.begin(); li != entryIncludes.end(); ++li) + { + if (testIsOff && !cmSystemTools::IsOff(li->c_str())) + { + cmSystemTools::ConvertToUnixSlashes(*li); + } + std::string inc = *li; + + if(uniqueIncludes.insert(inc).second) + { + includes.push_back(inc); + if (debugIncludes) + { + usedIncludes += " * " + inc + "\n"; + } + } + } + if (cacheIncludes) + { + (*it)->CachedIncludes = entryIncludes; + } + if (!usedIncludes.empty()) + { + mf->GetCMakeInstance()->IssueMessage(cmake::LOG, + std::string("Used includes for target ") + + tgt->GetName() + ":\n" + + usedIncludes, (*it)->ge->GetBacktrace()); + } + } +} + //---------------------------------------------------------------------------- std::vector cmTarget::GetIncludeDirectories(const char *config) { @@ -2788,63 +2862,50 @@ std::vector cmTarget::GetIncludeDirectories(const char *config) this->DebugIncludesDone = true; } - for (std::vector::const_iterator - it = this->Internal->IncludeDirectoriesEntries.begin(), - end = this->Internal->IncludeDirectoriesEntries.end(); + processIncludeDirectories(this, + this->Internal->IncludeDirectoriesEntries, + includes, + uniqueIncludes, + &dagChecker, + config, + debugIncludes); + + std::vector + linkInterfaceIncludeDirectoriesEntries; + + for (std::vector::const_iterator + it = this->Internal->LinkInterfaceIncludeDirectoriesEntries.begin(), + end = this->Internal->LinkInterfaceIncludeDirectoriesEntries.end(); it != end; ++it) { - - bool testIsOff = true; - bool cacheIncludes = false; - std::vector entryIncludes = (*it)->CachedIncludes; - if(!entryIncludes.empty()) + { + cmGeneratorExpression ge(lfbt); + cmsys::auto_ptr cge = ge.Parse(it->Value); + std::string result = cge->Evaluate(this->Makefile, config, + false, this, 0, 0); + if (!this->Makefile->FindTargetToUse(result.c_str())) { - testIsOff = false; - } - else - { - cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(this->Makefile, - config, - false, - this, - &dagChecker), - entryIncludes); - if (this->Makefile->IsGeneratingBuildSystem() - && !(*it)->ge->GetHadContextSensitiveCondition()) - { - cacheIncludes = true; - } - } - std::string usedIncludes; - for(std::vector::iterator - li = entryIncludes.begin(); li != entryIncludes.end(); ++li) - { - if (testIsOff && !cmSystemTools::IsOff(li->c_str())) - { - cmSystemTools::ConvertToUnixSlashes(*li); - } - std::string inc = *li; - - if(uniqueIncludes.insert(inc).second) - { - includes.push_back(inc); - if (debugIncludes) - { - usedIncludes += " * " + inc + "\n"; - } - } - } - if (cacheIncludes) - { - (*it)->CachedIncludes = entryIncludes; - } - if (!usedIncludes.empty()) - { - this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, - "Used includes for target " + this->Name + ":\n" - + usedIncludes, (*it)->ge->GetBacktrace()); + continue; } } + cmGeneratorExpression ge(it->Backtrace); + cmsys::auto_ptr cge = ge.Parse( + "$Value + ",INTERFACE_INCLUDE_DIRECTORIES>"); + + linkInterfaceIncludeDirectoriesEntries.push_back( + new cmTargetInternals::IncludeDirectoriesEntry(cge)); + } + + processIncludeDirectories(this, + linkInterfaceIncludeDirectoriesEntries, + includes, + uniqueIncludes, + &dagChecker, + config, + debugIncludes); + + deleteAndClear(linkInterfaceIncludeDirectoriesEntries); + return includes; } @@ -2858,23 +2919,57 @@ std::string cmTarget::GetCompileDefinitions(const char *config) } const char *prop = this->GetProperty(defPropName.c_str()); + cmListFileBacktrace lfbt; + cmGeneratorExpressionDAGChecker dagChecker(lfbt, + this->GetName(), + defPropName, 0, 0); - if (!prop) + std::string result; + if (prop) { - return ""; + cmGeneratorExpression ge(lfbt); + + result = ge.Parse(prop)->Evaluate(this->Makefile, + config, + false, + this, + &dagChecker); } - cmListFileBacktrace lfbt; - cmGeneratorExpression ge(lfbt); + std::vector libs; + this->GetDirectLinkLibraries(config, libs, this); - cmGeneratorExpressionDAGChecker dagChecker(lfbt, - this->GetName(), - defPropName, 0, 0); - return ge.Parse(prop)->Evaluate(this->Makefile, - config, - false, - this, - &dagChecker); + if (libs.empty()) + { + return result; + } + + std::string sep; + std::string depString; + for (std::vector::const_iterator it = libs.begin(); + it != libs.end(); ++it) + { + if (this->Makefile->FindTargetToUse(it->c_str())) + { + depString += sep + "$"; + sep = ";"; + } + } + + cmGeneratorExpression ge2(lfbt); + cmsys::auto_ptr cge2 = ge2.Parse(depString); + std::string depResult = cge2->Evaluate(this->Makefile, + config, + false, + this, + &dagChecker); + if (!depResult.empty()) + { + result += (result.empty() ? "" : ";") + depResult; + } + + return result; } //---------------------------------------------------------------------------- diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 028a55e53..e659baf1c 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -495,6 +495,7 @@ public: std::vector GetIncludeDirectories(const char *config); void InsertInclude(const cmValueWithOrigin &entry, bool before = false); + void AppendTllInclude(const cmValueWithOrigin &entry); void AppendBuildInterfaceIncludes(); diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index 9dd0e5be2..22ea92028 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -291,6 +291,14 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib, // Handle normal case first. if(this->CurrentProcessingState != ProcessingLinkInterface) { + { + cmListFileBacktrace lfbt; + this->Makefile->GetBacktrace(lfbt); + cmValueWithOrigin entry(this->Target->GetDebugGeneratorExpressions(lib, + llt), + lfbt); + this->Target->AppendTllInclude(entry); + } this->Makefile ->AddLinkLibraryForTarget(this->Target->GetName(), lib, llt); if (this->CurrentProcessingState != ProcessingPublicInterface) From 567c8d103ed3c3cb7303877d89e8508dd3f8d0ca Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 12 Feb 2013 11:53:36 +0100 Subject: [PATCH 05/10] Revert "Don't allow utility or global targets in the LINKED expression." This reverts commit 9712362b4580fb92394ecf8ff57be186571f4319. --- Source/cmGeneratorExpressionEvaluator.cxx | 8 -------- .../BadLinked-UtilityTarget-result.txt | 1 - .../BadLinked-UtilityTarget-stderr.txt | 8 -------- .../BadLinked-UtilityTarget.cmake | 7 ------- .../TargetPropertyGeneratorExpressions/RunCMakeTest.cmake | 1 - .../RunCMake/TargetPropertyGeneratorExpressions/empty.cpp | 1 - 6 files changed, 26 deletions(-) delete mode 100644 Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-UtilityTarget-result.txt delete mode 100644 Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-UtilityTarget-stderr.txt delete mode 100644 Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-UtilityTarget.cmake delete mode 100644 Tests/RunCMake/TargetPropertyGeneratorExpressions/empty.cpp diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 6c1c12a32..eb8cdc86a 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -759,14 +759,6 @@ private: { return std::string(); } - if(target->GetType() >= cmTarget::UTILITY && - target->GetType() != cmTarget::UNKNOWN_LIBRARY) - { - ::reportError(context, content->GetOriginalExpression(), - "Target \"" + item - + "\" is not an executable or library."); - return std::string(); - } std::string propertyName = "INTERFACE_" + prop; const char *propContent = target->GetProperty(propertyName.c_str()); if (!propContent) diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-UtilityTarget-result.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-UtilityTarget-result.txt deleted file mode 100644 index d00491fd7..000000000 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-UtilityTarget-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-UtilityTarget-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-UtilityTarget-stderr.txt deleted file mode 100644 index fb065540b..000000000 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-UtilityTarget-stderr.txt +++ /dev/null @@ -1,8 +0,0 @@ -CMake Error at BadLinked-UtilityTarget.cmake:7 \(set_property\): - Error evaluating generator expression: - - \$ - - Target "check" is not an executable or library. -Call Stack \(most recent call first\): - CMakeLists.txt:8 \(include\) diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-UtilityTarget.cmake b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-UtilityTarget.cmake deleted file mode 100644 index d114c8fc6..000000000 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-UtilityTarget.cmake +++ /dev/null @@ -1,7 +0,0 @@ - -add_custom_target(check ALL - COMMAND ${CMAKE_COMMAND} -E echo check -) - -add_library(foo STATIC empty.cpp) -set_property(TARGET foo PROPERTY INCLUDE_DIRECTORIES $) diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake b/Tests/RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake index 84039c437..ea48f61a8 100644 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake @@ -16,4 +16,3 @@ run_cmake(BadInvalidName6) run_cmake(BadInvalidName7) run_cmake(BadInvalidName8) run_cmake(BadLinked) -run_cmake(BadLinked-UtilityTarget) diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/empty.cpp b/Tests/RunCMake/TargetPropertyGeneratorExpressions/empty.cpp deleted file mode 100644 index 8b1a39374..000000000 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/empty.cpp +++ /dev/null @@ -1 +0,0 @@ -// empty From e1f908015f943ed507063260b3aae1f3b503237e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 12 Feb 2013 11:58:50 +0100 Subject: [PATCH 06/10] Don't populate INTERFACE includes and defines properties in tll. This is a partial revert of commit 77cecb77 (Add includes and compile definitions with target_link_libraries., 2012-11-05). As the interface includes and defines are now determined by the link closure, there is no need to populate the corresponding properties explicitly. --- Source/cmTargetLinkLibrariesCommand.cxx | 44 ------------------- .../DebugIncludes-stderr.txt | 21 ++++----- .../include_directories/DebugIncludes.cmake | 6 ++- 3 files changed, 16 insertions(+), 55 deletions(-) diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index 22ea92028..3f652c93c 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -251,43 +251,11 @@ cmTargetLinkLibrariesCommand this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); } -//---------------------------------------------------------------------------- -static std::string compileProperty(cmTarget *tgt, const std::string &lib, - bool isGenex, - const std::string &property, - cmTarget::LinkLibraryType llt) -{ - std::string value = !isGenex ? "$" - : "$<$:" + - "$" - ">"; - - return tgt->GetDebugGeneratorExpressions(value, llt); -} - //---------------------------------------------------------------------------- void cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib, cmTarget::LinkLibraryType llt) { - const bool isGenex = cmGeneratorExpression::Find(lib) != std::string::npos; - - const bool potentialTargetName - = cmGeneratorExpression::IsValidTargetName(lib); - - if (potentialTargetName || isGenex) - { - this->Target->AppendProperty("INCLUDE_DIRECTORIES", - compileProperty(this->Target, lib, - isGenex, - "INCLUDE_DIRECTORIES", llt).c_str()); - this->Target->AppendProperty("COMPILE_DEFINITIONS", - compileProperty(this->Target, lib, - isGenex, - "COMPILE_DEFINITIONS", llt).c_str()); - } - // Handle normal case first. if(this->CurrentProcessingState != ProcessingLinkInterface) { @@ -308,18 +276,6 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib, } } - if (potentialTargetName || isGenex) - { - this->Target->AppendProperty("INTERFACE_COMPILE_DEFINITIONS", - compileProperty(this->Target, lib, - isGenex, - "COMPILE_DEFINITIONS", llt).c_str()); - this->Target->AppendProperty("INTERFACE_INCLUDE_DIRECTORIES", - compileProperty(this->Target, lib, - isGenex, - "INCLUDE_DIRECTORIES", llt).c_str()); - } - // Get the list of configurations considered to be DEBUG. std::vector const& debugConfigs = this->Makefile->GetCMakeInstance()->GetDebugConfigs(); diff --git a/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt b/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt index c17e0ae02..63aec9052 100644 --- a/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt +++ b/Tests/RunCMake/include_directories/DebugIncludes-stderr.txt @@ -23,21 +23,22 @@ CMake Debug Log at DebugIncludes.cmake:18 \(include_directories\): Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) + -CMake Debug Log at DebugIncludes.cmake:26 \(target_link_libraries\): +CMake Debug Log at DebugIncludes.cmake:33 \(set_property\): Used includes for target lll: \* .*/Tests/RunCMake/include_directories/five - -Call Stack \(most recent call first\): - CMakeLists.txt:3 \(include\) -+ -CMake Debug Log at DebugIncludes.cmake:29 \(set_property\): - Used includes for target lll: - \* .*/Tests/RunCMake/include_directories/six \* .*/Tests/RunCMake/include_directories/seven Call Stack \(most recent call first\): - DebugIncludes.cmake:40 \(some_macro\) - DebugIncludes.cmake:43 \(some_function\) + DebugIncludes.cmake:44 \(some_macro\) + DebugIncludes.cmake:47 \(some_function\) + CMakeLists.txt:3 \(include\) ++ +CMake Debug Log at DebugIncludes.cmake:30 \(target_link_libraries\): + Used includes for target lll: + + \* .*/Tests/RunCMake/include_directories/eight + +Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/include_directories/DebugIncludes.cmake b/Tests/RunCMake/include_directories/DebugIncludes.cmake index 794a85253..de3689956 100644 --- a/Tests/RunCMake/include_directories/DebugIncludes.cmake +++ b/Tests/RunCMake/include_directories/DebugIncludes.cmake @@ -22,7 +22,11 @@ include_directories( ) add_library(foo "${CMAKE_CURRENT_BINARY_DIR}/DebugIncludes.cpp") -target_include_directories(foo INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/five") +target_include_directories(foo + INTERFACE + "${CMAKE_CURRENT_SOURCE_DIR}/seven" + "${CMAKE_CURRENT_SOURCE_DIR}/eight" +) target_link_libraries(lll foo) macro(some_macro) From 3df36b5954bef70891a666756d325e8bb4d01c1a Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 12 Feb 2013 11:56:58 +0100 Subject: [PATCH 07/10] Revert "Add the $ generator expression." This reverts commit 0b92602b816e2584db3781b120a1e5200da72ada. Conflicts: Source/cmGeneratorExpressionEvaluator.cxx Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt Tests/CMakeCommands/target_include_directories/CMakeLists.txt --- Source/cmDocumentGeneratorExpressions.h | 8 -- Source/cmExportFileGenerator.cxx | 66 ++----------- Source/cmExportFileGenerator.h | 4 +- Source/cmGeneratorExpressionEvaluator.cxx | 94 ------------------- .../target_compile_definitions/CMakeLists.txt | 6 -- .../target_compile_definitions/consumer.cpp | 4 - .../target_include_directories/CMakeLists.txt | 8 -- .../target_include_directories/consumer.cpp | 5 - .../BadLinked-result.txt | 1 - .../BadLinked-stderr.txt | 7 -- .../BadLinked.cmake | 7 -- .../RunCMakeTest.cmake | 1 - 12 files changed, 8 insertions(+), 203 deletions(-) delete mode 100644 Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-result.txt delete mode 100644 Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-stderr.txt delete mode 100644 Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked.cmake diff --git a/Source/cmDocumentGeneratorExpressions.h b/Source/cmDocumentGeneratorExpressions.h index 3993f7d72..8b80a8a32 100644 --- a/Source/cmDocumentGeneratorExpressions.h +++ b/Source/cmDocumentGeneratorExpressions.h @@ -51,14 +51,6 @@ "on the target tgt.\n" \ "Note that tgt is not added as a dependency of the target this " \ "expression is evaluated on.\n" \ - " $ = An empty string if item is not a " \ - "target. If item is a target then the " \ - "INTERFACE_INCLUDE_DIRECTORIES or INTERFACE_COMPILE_DEFINITIONS " \ - "content is read from the target. " \ - "This generator expression can only be used in evaluation of the " \ - "INCLUDE_DIRECTORIES or COMPILE_DEFINITIONS property. Note that " \ - "this expression is for internal use and may be changed or removed " \ - "in the future.\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 " \ diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index fbed95a8b..ee8436c94 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -25,8 +25,6 @@ #include -#include "assert.h" - //---------------------------------------------------------------------------- cmExportFileGenerator::cmExportFileGenerator() { @@ -162,7 +160,7 @@ void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName, preprocessRule); if (!prepro.empty()) { - this->ResolveTargetsInGeneratorExpressions(prepro, target, propName, + this->ResolveTargetsInGeneratorExpressions(prepro, target, missingTargets); properties[outputName] = prepro; } @@ -318,14 +316,13 @@ cmExportFileGenerator::AddTargetNamespace(std::string &input, void cmExportFileGenerator::ResolveTargetsInGeneratorExpressions( std::string &input, - cmTarget* target, const char *propName, + cmTarget* target, std::vector &missingTargets, FreeTargetsReplace replace) { if (replace == NoReplaceFreeTargets) { - this->ResolveTargetsInGeneratorExpression(input, target, propName, - missingTargets); + this->ResolveTargetsInGeneratorExpression(input, target, missingTargets); return; } std::vector parts; @@ -344,7 +341,7 @@ cmExportFileGenerator::ResolveTargetsInGeneratorExpressions( { this->ResolveTargetsInGeneratorExpression( *li, - target, propName, + target, missingTargets); } input += sep + *li; @@ -356,7 +353,7 @@ cmExportFileGenerator::ResolveTargetsInGeneratorExpressions( void cmExportFileGenerator::ResolveTargetsInGeneratorExpression( std::string &input, - cmTarget* target, const char *propName, + cmTarget* target, std::vector &missingTargets) { std::string::size_type pos = 0; @@ -391,57 +388,6 @@ cmExportFileGenerator::ResolveTargetsInGeneratorExpression( } std::string errorString; - pos = 0; - lastPos = pos; - while((pos = input.find("$", nameStartPos); - if (endPos == input.npos) - { - errorString = "$ expression incomplete"; - break; - } - std::string targetName = input.substr(nameStartPos, - endPos - nameStartPos); - if(targetName.find("$<") != input.npos) - { - errorString = "$ requires its parameter to be a " - "literal."; - break; - } - if (this->AddTargetNamespace(targetName, target, missingTargets)) - { - assert(propName); // The link libraries strings will - // never contain $ - std::string replacement = "$IssueMessage(cmake::FATAL_ERROR, errorString); - return; - } - pos = 0; lastPos = pos; while((pos = input.find("$ResolveTargetsInGeneratorExpressions(prepro, target, 0, + this->ResolveTargetsInGeneratorExpressions(prepro, target, missingTargets, ReplaceFreeTargets); properties["IMPORTED_LINK_INTERFACE_LIBRARIES" + suffix] = prepro; diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 5ad27bfaf..776be614d 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -119,7 +119,7 @@ protected: }; void ResolveTargetsInGeneratorExpressions(std::string &input, - cmTarget* target, const char *propName, + cmTarget* target, std::vector &missingTargets, FreeTargetsReplace replace = NoReplaceFreeTargets); @@ -150,7 +150,7 @@ private: std::vector &missingTargets); void ResolveTargetsInGeneratorExpression(std::string &input, - cmTarget* target, const char *propName, + cmTarget* target, std::vector &missingTargets); virtual void ReplaceInstallPrefix(std::string &input); diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index eb8cdc86a..cd6a40b8d 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -712,98 +712,6 @@ static const struct InstallPrefixNode : public cmGeneratorExpressionNode } installPrefixNode; -//---------------------------------------------------------------------------- -static const struct LinkedNode : public cmGeneratorExpressionNode -{ - LinkedNode() {} - - virtual bool GeneratesContent() const { return true; } - virtual int NumExpectedParameters() const { return 1; } - virtual bool RequiresLiteralInput() const { return true; } - - std::string Evaluate(const std::vector ¶meters, - cmGeneratorExpressionContext *context, - const GeneratorExpressionContent *content, - cmGeneratorExpressionDAGChecker *dagChecker) const - { - if (dagChecker->EvaluatingIncludeDirectories()) - { - return this->GetInterfaceProperty(parameters.front(), - "INCLUDE_DIRECTORIES", - context, content, dagChecker); - } - if (dagChecker->EvaluatingCompileDefinitions()) - { - return this->GetInterfaceProperty(parameters.front(), - "COMPILE_DEFINITIONS", - context, content, dagChecker); - } - - reportError(context, content->GetOriginalExpression(), - "$ may only be used in INCLUDE_DIRECTORIES and " - "COMPILE_DEFINITIONS properties."); - - return std::string(); - } - -private: - std::string GetInterfaceProperty(const std::string &item, - const std::string &prop, - cmGeneratorExpressionContext *context, - const GeneratorExpressionContent *content, - cmGeneratorExpressionDAGChecker *dagCheckerParent) const - { - cmTarget *target = context->CurrentTarget - ->GetMakefile()->FindTargetToUse(item.c_str()); - if (!target) - { - return std::string(); - } - std::string propertyName = "INTERFACE_" + prop; - const char *propContent = target->GetProperty(propertyName.c_str()); - if (!propContent) - { - return std::string(); - } - - cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace, - target->GetName(), - propertyName, - content, - dagCheckerParent); - - switch (dagChecker.check()) - { - case cmGeneratorExpressionDAGChecker::SELF_REFERENCE: - dagChecker.reportError(context, content->GetOriginalExpression()); - return std::string(); - case cmGeneratorExpressionDAGChecker::CYCLIC_REFERENCE: - // No error. We just skip cyclic references. - return std::string(); - case cmGeneratorExpressionDAGChecker::ALREADY_SEEN: - // No error. We're not going to find anything new here. - return std::string(); - case cmGeneratorExpressionDAGChecker::DAG: - break; - } - - cmGeneratorExpression ge(context->Backtrace); - cmsys::auto_ptr cge = ge.Parse(propContent); - std::string result = cge->Evaluate(context->Makefile, - context->Config, - context->Quiet, - context->HeadTarget, - target, - &dagChecker); - if (cge->GetHadContextSensitiveCondition()) - { - context->HadContextSensitiveCondition = true; - } - return result; - } - -} linkedNode; - //---------------------------------------------------------------------------- template struct TargetFilesystemArtifactResultCreator @@ -1038,8 +946,6 @@ cmGeneratorExpressionNode* GetNode(const std::string &identifier) return &targetDefinedNode; else if (identifier == "INSTALL_PREFIX") return &installPrefixNode; - else if (identifier == "LINKED") - return &linkedNode; return 0; } diff --git a/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt index 8fed4ca48..8a4437ba5 100644 --- a/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt +++ b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt @@ -16,15 +16,9 @@ add_executable(consumer "${CMAKE_CURRENT_SOURCE_DIR}/consumer.cpp" ) -add_library(linked UNKNOWN IMPORTED) -set_property(TARGET linked PROPERTY - INTERFACE_COMPILE_DEFINITIONS "MY_LINKED_DEFINE") - - target_compile_definitions(consumer PRIVATE $ $<$:SHOULD_NOT_BE_DEFINED> $<$:SHOULD_BE_DEFINED> - $ -DDASH_D_DEFINE ) diff --git a/Tests/CMakeCommands/target_compile_definitions/consumer.cpp b/Tests/CMakeCommands/target_compile_definitions/consumer.cpp index c07759358..1a46aa50c 100644 --- a/Tests/CMakeCommands/target_compile_definitions/consumer.cpp +++ b/Tests/CMakeCommands/target_compile_definitions/consumer.cpp @@ -23,8 +23,4 @@ #error Expected DASH_D_DEFINE #endif -#ifndef MY_LINKED_DEFINE -#error Expected MY_LINKED_DEFINE -#endif - int main() { return 0; } diff --git a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt index 2c2ca42a6..c2da17564 100644 --- a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt +++ b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt @@ -17,9 +17,6 @@ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/poison/common.h" "#error Should not be i file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/cure") file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cure/common.h" "#define CURE_DEFINE\n") -file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/linkedinclude") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/linkedinclude/linkedinclude.h" "#define LINKEDINCLUDE_DEFINE\n") - add_executable(target_include_directories "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp" ) @@ -45,13 +42,8 @@ add_executable(consumer "${CMAKE_CURRENT_SOURCE_DIR}/consumer.cpp" ) -add_library(linked UNKNOWN IMPORTED) -set_property(TARGET linked PROPERTY - INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/linkedinclude") - target_include_directories(consumer PRIVATE $ - $ relative_dir ) diff --git a/Tests/CMakeCommands/target_include_directories/consumer.cpp b/Tests/CMakeCommands/target_include_directories/consumer.cpp index ccffd9cab..82b800a40 100644 --- a/Tests/CMakeCommands/target_include_directories/consumer.cpp +++ b/Tests/CMakeCommands/target_include_directories/consumer.cpp @@ -3,7 +3,6 @@ #include "publicinclude.h" #include "interfaceinclude.h" #include "relative_dir.h" -#include "linkedinclude.h" #ifdef PRIVATEINCLUDE_DEFINE #error Unexpected PRIVATEINCLUDE_DEFINE @@ -25,8 +24,4 @@ #error Expected RELATIVE_DIR_DEFINE #endif -#ifndef LINKEDINCLUDE_DEFINE -#error Expected LINKEDINCLUDE_DEFINE -#endif - int main() { return 0; } diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-result.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-result.txt deleted file mode 100644 index d00491fd7..000000000 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-result.txt +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-stderr.txt deleted file mode 100644 index 4cd9cdd15..000000000 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-stderr.txt +++ /dev/null @@ -1,7 +0,0 @@ -CMake Error: - Error evaluating generator expression: - - \$ - - \$ may only be used in INCLUDE_DIRECTORIES and - COMPILE_DEFINITIONS properties.$ diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked.cmake b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked.cmake deleted file mode 100644 index 542ea760e..000000000 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked.cmake +++ /dev/null @@ -1,7 +0,0 @@ - -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp" - "int main(int, char **) { return 0; }\n") - -add_executable(TargetPropertyGeneratorExpressions - "${CMAKE_CURRENT_BINARY_DIR}/main.cpp") -target_link_libraries(TargetPropertyGeneratorExpressions "$") diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake b/Tests/RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake index ea48f61a8..0ee32387d 100644 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake @@ -15,4 +15,3 @@ run_cmake(BadInvalidName5) run_cmake(BadInvalidName6) run_cmake(BadInvalidName7) run_cmake(BadInvalidName8) -run_cmake(BadLinked) From 71bf96ec78afef09dc0b927f6dcebeb9b3208db1 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 12 Feb 2013 12:00:31 +0100 Subject: [PATCH 08/10] Revert "find_package: Reword _NO_INTERFACES documentation" This reverts commit 179f49560286e2e322b9b0cf5d0a277b7634540f. --- Source/cmFindPackageCommand.cxx | 35 +++++++++++++++++---------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 6e78bd7e5..e9b6ab636 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -376,25 +376,26 @@ void cmFindPackageCommand::GenerateDocumentation() "The package configuration file may set _FOUND to false " "to tell find_package that component requirements are not satisfied." "\n" - "A package configuration file may include() a Targets.cmake " - "file, created by install(EXPORT) in the upstream source, to import " - "targets into the downstream consumer. " - "When a new version of the upstream adds INTERFACE properties not " - "present in a previous version it can change behavior for existing " - "downstreams. " - "In order to remain source compatible the upstream package configuration " - "file may set _NO_INTERFACES to disable INTERFACE properties. " - "For example, code of the form:\n" - " if(_FIND_VERSION VERSION_LESS \n" - " AND NOT _INTERFACES)\n" - " set(_NO_INTERFACES 1)\n" + "Targets exported by the install() command may have additional INTERFACE " + "properties set for include directories, compile definitions etc. As " + "these may create a backward compatibility concern for consumers of " + "existing projects, it is possible to set the _NO_INTERFACES " + "variable to disable populating those interfaces. It is possible to " + "emulate a version-based policy for whether the interfaces should be " + "enabled in the config file before including the imported targets file. " + "This allows consumers to decide when to enable the new interfaces when " + "upgrading. The upstream project is responsible for adding code similar " + "to this in the version which generates the INTERFACE content:\n" + " if(${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION VERSION_LESS 2.3\n" + " AND NOT ${CMAKE_FIND_PACKAGE_NAME}_INTERFACES)\n" + " set(${CMAKE_FIND_PACKAGE_NAME}_NO_INTERFACES 1)\n" " endif()\n" " include(\"${CMAKE_CURRENT_LIST_DIR}/Targets.cmake\")\n" - "tells Targets.cmake not to provide the INTERFACE properties " - "unless the downstream requests at least or sets " - "_INTERFACES to explicitly request them. " - "This allows consumers to decide when to enable the new interfaces when " - "upgrading." + "\n" + "Downstream users may then choose to use the new interfaces by finding " + "the newer version of upstream. They can also choose to not use the new " + "interfaces by setting _INTERFACES to false before finding the " + "package.\n" "\n" "See the cmake_policy() command documentation for discussion of the " "NO_POLICY_SCOPE option." From 79ae968a18ea58219df419a4add55f054889be31 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 12 Feb 2013 12:00:41 +0100 Subject: [PATCH 09/10] Revert "Add a way to exclude INTERFACE properties from exported targets." This reverts commit 2c3654c3de718fe822f8960063373774fc019494. The removal of some tests added in commit 77cecb77 (Add includes and compile definitions with target_link_libraries., 2012-11-05) are also squashed into this commit. --- Source/cmExportFileGenerator.cxx | 7 +++--- Source/cmFindPackageCommand.cxx | 21 ---------------- Tests/ExportImport/Import/CMakeLists.txt | 5 ---- .../Import/package_new_new/CMakeLists.txt | 23 ------------------ .../Import/package_new_old/CMakeLists.txt | 24 ------------------- .../Import/package_old_old/CMakeLists.txt | 24 ------------------- 6 files changed, 3 insertions(+), 101 deletions(-) delete mode 100644 Tests/ExportImport/Import/package_new_new/CMakeLists.txt delete mode 100644 Tests/ExportImport/Import/package_new_old/CMakeLists.txt delete mode 100644 Tests/ExportImport/Import/package_old_old/CMakeLists.txt diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index ee8436c94..ef4ea3800 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -264,16 +264,15 @@ void cmExportFileGenerator::GenerateInterfaceProperties(cmTarget *target, { if (!properties.empty()) { - os << "if(NOT ${CMAKE_FIND_PACKAGE_NAME}_NO_INTERFACES)\n"; 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) { - os << " " << pi->first << " \"" << pi->second << "\"\n"; + os << " " << pi->first << " \"" << pi->second << "\"\n"; } - os << " )\nendif()\n\n"; + os << ")\n\n"; } } diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index e9b6ab636..470cecabe 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -376,27 +376,6 @@ void cmFindPackageCommand::GenerateDocumentation() "The package configuration file may set _FOUND to false " "to tell find_package that component requirements are not satisfied." "\n" - "Targets exported by the install() command may have additional INTERFACE " - "properties set for include directories, compile definitions etc. As " - "these may create a backward compatibility concern for consumers of " - "existing projects, it is possible to set the _NO_INTERFACES " - "variable to disable populating those interfaces. It is possible to " - "emulate a version-based policy for whether the interfaces should be " - "enabled in the config file before including the imported targets file. " - "This allows consumers to decide when to enable the new interfaces when " - "upgrading. The upstream project is responsible for adding code similar " - "to this in the version which generates the INTERFACE content:\n" - " if(${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION VERSION_LESS 2.3\n" - " AND NOT ${CMAKE_FIND_PACKAGE_NAME}_INTERFACES)\n" - " set(${CMAKE_FIND_PACKAGE_NAME}_NO_INTERFACES 1)\n" - " endif()\n" - " include(\"${CMAKE_CURRENT_LIST_DIR}/Targets.cmake\")\n" - "\n" - "Downstream users may then choose to use the new interfaces by finding " - "the newer version of upstream. They can also choose to not use the new " - "interfaces by setting _INTERFACES to false before finding the " - "package.\n" - "\n" "See the cmake_policy() command documentation for discussion of the " "NO_POLICY_SCOPE option." ; diff --git a/Tests/ExportImport/Import/CMakeLists.txt b/Tests/ExportImport/Import/CMakeLists.txt index 237f8faa8..3fc78a280 100644 --- a/Tests/ExportImport/Import/CMakeLists.txt +++ b/Tests/ExportImport/Import/CMakeLists.txt @@ -17,8 +17,3 @@ add_executable(imp_testTransExe1 imp_testTransExe1.c) target_link_libraries(imp_testTransExe1 imp_lib1) add_executable(imp_testTransExe1b imp_testTransExe1.c) target_link_libraries(imp_testTransExe1b imp_lib1b) - -# Test package INTERFACE controls -add_subdirectory(package_old_old) -add_subdirectory(package_new_old) -add_subdirectory(package_new_new) diff --git a/Tests/ExportImport/Import/package_new_new/CMakeLists.txt b/Tests/ExportImport/Import/package_new_new/CMakeLists.txt deleted file mode 100644 index 4e6f642d3..000000000 --- a/Tests/ExportImport/Import/package_new_new/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ - -cmake_minimum_required(VERSION 2.8) - -find_package(testLibRequired 2.5 REQUIRED) - -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp" - " -#include \"testSharedLibRequired.h\" -int main(int argc, char **argv) -{ - TestSharedLibRequired req; - return req.foo(); -} -" -) - -get_target_property(prop Req::testSharedLibRequired INTERFACE_INCLUDE_DIRECTORIES) -if (NOT prop) - message(SEND_ERROR "Interface of Req::testSharedLibRequired should not be empty") -endif() - -add_executable(new_new_test "${CMAKE_CURRENT_BINARY_DIR}/main.cpp") -target_link_libraries(new_new_test Req::testSharedLibRequired) diff --git a/Tests/ExportImport/Import/package_new_old/CMakeLists.txt b/Tests/ExportImport/Import/package_new_old/CMakeLists.txt deleted file mode 100644 index e675d64b8..000000000 --- a/Tests/ExportImport/Import/package_new_old/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ - -cmake_minimum_required(VERSION 2.8) - -find_package(testLibRequired 2.5 REQUIRED) - -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp" - " -#include \"testSharedLibRequired.h\" -int main(int argc, char **argv) -{ - TestSharedLibRequired req; - return req.foo(); -} -" -) - -get_target_property(prop Req::testSharedLibRequired INTERFACE_INCLUDE_DIRECTORIES) -if ("${prop}" STREQUAL "") - message(SEND_ERROR "Interface of Req::testSharedLibRequired should not be empty") -endif() - -add_executable(new_old_test "${CMAKE_CURRENT_BINARY_DIR}/main.cpp") -target_link_libraries(new_old_test Req::testSharedLibRequired) -include_directories(${testLibRequired_INCLUDE_DIRS}) diff --git a/Tests/ExportImport/Import/package_old_old/CMakeLists.txt b/Tests/ExportImport/Import/package_old_old/CMakeLists.txt deleted file mode 100644 index 3b2733042..000000000 --- a/Tests/ExportImport/Import/package_old_old/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ - -cmake_minimum_required(VERSION 2.8) - -find_package(testLibRequired 2.1 REQUIRED) - -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp" - " -#include \"testSharedLibRequired.h\" -int main(int argc, char **argv) -{ - TestSharedLibRequired req; - return req.foo(); -} -" -) - -get_target_property(prop Req::testSharedLibRequired INTERFACE_INCLUDE_DIRECTORIES) -if (prop) - message(SEND_ERROR "Interface of Req::testSharedLibRequired should be empty, but is ${prop}") -endif() - -add_executable(old_old_test "${CMAKE_CURRENT_BINARY_DIR}/main.cpp") -target_link_libraries(old_old_test Req::testSharedLibRequired) -include_directories(${testLibRequired_INCLUDE_DIRS}) From fde949d1434c450914a8eab874940b3de074783c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 12 Feb 2013 12:05:40 +0100 Subject: [PATCH 10/10] Don't add target-specific interface includes and defines to Qt 4 targets. This is a partial revert of commit c8ee07d0 (FindQt4: Add INTERFACE includes and defines to Qt4 targets, 2012-12-31). --- Modules/FindQt4.cmake | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index 5baee01cb..078c03189 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -972,14 +972,6 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION) ${_PROPERTY} "Qt4::Qt${_DEPEND}" ) - set_property(TARGET Qt4::${_QT_MODULE} APPEND PROPERTY - INTERFACE_INCLUDE_DIRECTORIES - "$" - ) - set_property(TARGET Qt4::${_QT_MODULE} APPEND PROPERTY - INTERFACE_COMPILE_DEFINITIONS - "$" - ) endforeach() endif() endmacro()