diff options
Diffstat (limited to 'Source')
52 files changed, 910 insertions, 360 deletions
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 2c3a64b..80d424e 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 11) -set(CMake_VERSION_TWEAK 20130711) +set(CMake_VERSION_TWEAK 20130715) #set(CMake_VERSION_RC 1) diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 0ba0139..ab9eb14 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -1884,8 +1884,6 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, } if(use_build_rpath || use_link_rpath) { - std::string rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT"); - cmSystemTools::ConvertToUnixSlashes(rootPath); std::vector<std::string> const& rdirs = this->GetRuntimeSearchPath(); for(std::vector<std::string>::const_iterator ri = rdirs.begin(); ri != rdirs.end(); ++ri) @@ -1909,14 +1907,9 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, !cmSystemTools::IsSubDirectory(ri->c_str(), topSourceDir) && !cmSystemTools::IsSubDirectory(ri->c_str(), topBinaryDir)) { - std::string d = *ri; - if (d.find(rootPath) == 0) + if(emitted.insert(*ri).second) { - d = d.substr(rootPath.size()); - } - if(emitted.insert(d).second) - { - runtimeDirs.push_back(d); + runtimeDirs.push_back(*ri); } } } diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 8fd95b9..0829add 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -282,6 +282,8 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, if(emitted.insert(*lib).second) { this->AddTargetDepend(depender_index, lib->c_str(), true); + this->AddInterfaceDepends(depender_index, lib->c_str(), + true, emitted); } } } diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 860417f..086f27a 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -12,6 +12,7 @@ #include "cmCoreTryCompile.h" #include "cmake.h" #include "cmCacheManager.h" +#include "cmLocalGenerator.h" #include "cmGlobalGenerator.h" #include "cmExportTryCompileFileGenerator.h" #include <cmsys/Directory.hxx> @@ -32,18 +33,20 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) std::vector<std::string> compileDefs; std::string outputVariable; std::string copyFile; + std::string copyFileError; std::vector<cmTarget*> targets; std::string libsToLink = " "; bool useOldLinkLibs = true; char targetNameBuf[64]; bool didOutputVariable = false; bool didCopyFile = false; + bool didCopyFileError = false; bool useSources = argv[2] == "SOURCES"; std::vector<std::string> sources; enum Doing { DoingNone, DoingCMakeFlags, DoingCompileDefinitions, DoingLinkLibraries, DoingOutputVariable, DoingCopyFile, - DoingSources }; + DoingCopyFileError, DoingSources }; Doing doing = useSources? DoingSources : DoingNone; for(size_t i=3; i < argv.size(); ++i) { @@ -74,6 +77,11 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) doing = DoingCopyFile; didCopyFile = true; } + else if(argv[i] == "COPY_FILE_ERROR") + { + doing = DoingCopyFileError; + didCopyFileError = true; + } else if(doing == DoingCMakeFlags) { cmakeFlags.push_back(argv[i]); @@ -121,6 +129,11 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) copyFile = argv[i].c_str(); doing = DoingNone; } + else if(doing == DoingCopyFileError) + { + copyFileError = argv[i].c_str(); + doing = DoingNone; + } else if(doing == DoingSources) { sources.push_back(argv[i]); @@ -149,6 +162,20 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) return -1; } + if(didCopyFileError && copyFileError.empty()) + { + this->Makefile->IssueMessage(cmake::FATAL_ERROR, + "COPY_FILE_ERROR must be followed by a variable name"); + return -1; + } + + if(didCopyFileError && !didCopyFile) + { + this->Makefile->IssueMessage(cmake::FATAL_ERROR, + "COPY_FILE_ERROR may be used only with COPY_FILE"); + return -1; + } + if(didOutputVariable && outputVariable.empty()) { this->Makefile->IssueMessage(cmake::FATAL_ERROR, @@ -214,8 +241,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) } // Detect languages to enable. - cmGlobalGenerator* gg = - this->Makefile->GetCMakeInstance()->GetGlobalGenerator(); + cmLocalGenerator* lg = this->Makefile->GetLocalGenerator(); + cmGlobalGenerator* gg = lg->GetGlobalGenerator(); std::set<std::string> testLangs; for(std::vector<std::string>::iterator si = sources.begin(); si != sources.end(); ++si) @@ -295,13 +322,12 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) for(std::set<std::string>::iterator li = testLangs.begin(); li != testLangs.end(); ++li) { - fprintf(fout, "SET(CMAKE_%s_FLAGS \"", li->c_str()); std::string langFlags = "CMAKE_" + *li + "_FLAGS"; - if(const char* flags = this->Makefile->GetDefinition(langFlags.c_str())) - { - fprintf(fout, " %s ", flags); - } - fprintf(fout, " ${COMPILE_DEFINITIONS}\")\n"); + const char* flags = this->Makefile->GetDefinition(langFlags.c_str()); + fprintf(fout, "SET(CMAKE_%s_FLAGS %s)\n", li->c_str(), + lg->EscapeForCMake(flags?flags:"").c_str()); + fprintf(fout, "SET(CMAKE_%s_FLAGS \"${CMAKE_%s_FLAGS}" + " ${COMPILE_DEFINITIONS}\")\n", li->c_str(), li->c_str()); } fprintf(fout, "INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES})\n"); fprintf(fout, "SET(CMAKE_SUPPRESS_REGENERATION 1)\n"); @@ -444,6 +470,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) if (this->SrcFileSignature) { + std::string copyFileErrorMessage; this->FindOutputFile(targetName); if ((res==0) && (copyFile.size())) @@ -461,10 +488,23 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) { emsg << this->FindErrorMessage.c_str(); } - this->Makefile->IssueMessage(cmake::FATAL_ERROR, emsg.str()); - return -1; + if(copyFileError.empty()) + { + this->Makefile->IssueMessage(cmake::FATAL_ERROR, emsg.str()); + return -1; + } + else + { + copyFileErrorMessage = emsg.str(); + } } } + + if(!copyFileError.empty()) + { + this->Makefile->AddDefinition(copyFileError.c_str(), + copyFileErrorMessage.c_str()); + } } return res; } diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index 0f89084..fcaa169 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -568,16 +568,6 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "Variables That Change Behavior"); cm->DefineProperty - ("CMAKE_SYSROOT", cmProperty::VARIABLE, - "Path to pass to the compiler in the --sysroot flag.", - "The CMAKE_SYSROOT content is passed to the compiler in the --sysroot " - "flag, if supported. The path is also stripped from the RPATH if " - "necessary on installation. The CMAKE_SYSROOT is also used to prefix " - "paths searched by the find_* commands.", - false, - "Variables That Change Behavior"); - - cm->DefineProperty ("CMAKE_FIND_LIBRARY_PREFIXES", cmProperty::VARIABLE, "Prefixes to prepend when looking for libraries.", "This specifies what prefixes to add to library names when " diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 326663c..cdc3316 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -77,6 +77,15 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) properties, missingTargets); this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", te, properties); + const bool newCMP0022Behavior = + te->GetPolicyStatusCMP0022() != cmPolicies::WARN + && te->GetPolicyStatusCMP0022() != cmPolicies::OLD; + if (newCMP0022Behavior) + { + this->PopulateInterfaceLinkLibrariesProperty(te, + cmGeneratorExpression::BuildInterface, + properties, missingTargets); + } this->PopulateCompatibleInterfaceProperties(te, properties); this->GenerateInterfaceProperties(te, os, properties); diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx index ffa8b51..9c3f314 100644 --- a/Source/cmExportCommand.cxx +++ b/Source/cmExportCommand.cxx @@ -30,6 +30,7 @@ cmExportCommand::cmExportCommand() ,Append(&Helper, "APPEND", &ArgumentGroup) ,Namespace(&Helper, "NAMESPACE", &ArgumentGroup) ,Filename(&Helper, "FILE", &ArgumentGroup) +,ExportOld(&Helper, "EXPORT_LINK_INTERFACE_LIBRARIES", &ArgumentGroup) { // at first TARGETS this->Targets.Follows(0); @@ -158,6 +159,7 @@ bool cmExportCommand ebfg.SetAppendMode(this->Append.IsEnabled()); ebfg.SetExports(&targets); ebfg.SetCommand(this); + ebfg.SetExportOld(this->ExportOld.IsEnabled()); // Compute the set of configurations exported. std::vector<std::string> configurationTypes; diff --git a/Source/cmExportCommand.h b/Source/cmExportCommand.h index ae67b47..87c3452 100644 --- a/Source/cmExportCommand.h +++ b/Source/cmExportCommand.h @@ -63,7 +63,7 @@ public: { return " export(TARGETS [target1 [target2 [...]]] [NAMESPACE <namespace>]\n" - " [APPEND] FILE <filename>)\n" + " [APPEND] FILE <filename> [EXPORT_LINK_INTERFACE_LIBRARIES])\n" "Create a file <filename> that may be included by outside projects to " "import targets from the current project's build tree. " "This is useful during cross-compiling to build utility executables " @@ -73,6 +73,10 @@ public: "prepended to all target names written to the file. " "If the APPEND option is given the generated code will be appended " "to the file instead of overwriting it. " + "The EXPORT_LINK_INTERFACE_LIBRARIES keyword, if present, causes the " + "contents of the properties matching " + "(IMPORTED_)?LINK_INTERFACE_LIBRARIES(_<CONFIG>)? to be exported, when " + "policy CMP0022 is NEW. " "If a library target is included in the export but " "a target to which it links is not included the behavior is " "unspecified." @@ -104,6 +108,7 @@ private: cmCAEnabler Append; cmCAString Namespace; cmCAString Filename; + cmCAEnabler ExportOld; friend class cmExportBuildFileGenerator; std::string ErrorMessage; diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 6bef017..b4e6e81 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -30,6 +30,7 @@ cmExportFileGenerator::cmExportFileGenerator() { this->AppendMode = false; + this->ExportOld = false; } //---------------------------------------------------------------------------- @@ -168,6 +169,39 @@ void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName, } } +void cmExportFileGenerator::GenerateRequiredCMakeVersion(std::ostream& os, + const char *versionString) +{ + os << "if(CMAKE_VERSION VERSION_LESS " << versionString << ")\n" + " message(FATAL_ERROR \"This file relies on consumers using " + "CMake " << versionString << " or greater.\")\n" + "endif()\n\n"; +} + +//---------------------------------------------------------------------------- +bool cmExportFileGenerator::PopulateInterfaceLinkLibrariesProperty( + cmTarget *target, + cmGeneratorExpression::PreprocessContext preprocessRule, + ImportPropertyMap &properties, + std::vector<std::string> &missingTargets) +{ + const char *input = target->GetProperty("INTERFACE_LINK_LIBRARIES"); + if (input) + { + std::string prepro = cmGeneratorExpression::Preprocess(input, + preprocessRule); + if (!prepro.empty()) + { + this->ResolveTargetsInGeneratorExpressions(prepro, target, + missingTargets, + ReplaceFreeTargets); + properties["INTERFACE_LINK_LIBRARIES"] = prepro; + return true; + } + } + return false; +} + //---------------------------------------------------------------------------- static bool isSubDirectory(const char* a, const char* b) { @@ -583,6 +617,22 @@ cmExportFileGenerator return; } + const bool newCMP0022Behavior = + target->GetPolicyStatusCMP0022() != cmPolicies::WARN + && target->GetPolicyStatusCMP0022() != cmPolicies::OLD; + + if(newCMP0022Behavior && !this->ExportOld) + { + cmMakefile *mf = target->GetMakefile(); + cmOStringStream e; + e << "Target \"" << target->GetName() << "\" has policy CMP0022 enabled, " + "but also has old-style INTERFACE_LINK_LIBRARIES properties " + "populated, but it was exported without the " + "EXPORT_LINK_INTERFACE_LIBRARIES to export the old-style properties"; + mf->IssueMessage(cmake::FATAL_ERROR, e.str()); + return; + } + if (!*propContent) { properties["IMPORTED_LINK_INTERFACE_LIBRARIES" + suffix] = ""; diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index ed2d93b..a624ba6 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -35,6 +35,8 @@ public: /** Set the namespace in which to place exported target names. */ void SetNamespace(const char* ns) { this->Namespace = ns; } + void SetExportOld(bool exportOld) { this->ExportOld = exportOld; } + /** Add a configuration to be exported. */ void AddConfiguration(const char* config); @@ -101,6 +103,10 @@ protected: cmGeneratorExpression::PreprocessContext, ImportPropertyMap &properties, std::vector<std::string> &missingTargets); + bool PopulateInterfaceLinkLibrariesProperty(cmTarget *target, + cmGeneratorExpression::PreprocessContext, + ImportPropertyMap &properties, + std::vector<std::string> &missingTargets); void PopulateInterfaceProperty(const char *propName, cmTarget *target, ImportPropertyMap &properties); void PopulateCompatibleInterfaceProperties(cmTarget *target, @@ -128,9 +134,14 @@ protected: std::vector<std::string> &missingTargets, FreeTargetsReplace replace = NoReplaceFreeTargets); + void GenerateRequiredCMakeVersion(std::ostream& os, + const char *versionString); + // The namespace in which the exports are placed in the generated file. std::string Namespace; + bool ExportOld; + // The set of configurations to export. std::vector<std::string> Configurations; diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index a966b16..560882e 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -113,6 +113,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) std::vector<std::string> missingTargets; + bool require2_8_12 = false; // Create all the imported targets. for(std::vector<cmTarget*>::const_iterator tei = allTargets.begin(); @@ -134,6 +135,20 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) te, cmGeneratorExpression::InstallInterface, properties, missingTargets); + + const bool newCMP0022Behavior = + te->GetPolicyStatusCMP0022() != cmPolicies::WARN + && te->GetPolicyStatusCMP0022() != cmPolicies::OLD; + if (newCMP0022Behavior) + { + if (this->PopulateInterfaceLinkLibrariesProperty(te, + cmGeneratorExpression::InstallInterface, + properties, missingTargets) + && !this->ExportOld) + { + require2_8_12 = true; + } + } this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", te, properties); this->PopulateCompatibleInterfaceProperties(te, properties); @@ -141,6 +156,10 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) this->GenerateInterfaceProperties(te, os, properties); } + if (require2_8_12) + { + this->GenerateRequiredCMakeVersion(os, "2.8.11.20130626"); + } // Now load per-configuration properties for them. os << "# Load information for each installed configuration.\n" diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index f6f4cef..dfbb1c0 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -621,19 +621,15 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, ->GetGeneratorTarget(target); // the compilerdefines for this target - std::string cdefs = target->GetCompileDefinitions(buildType); + std::vector<std::string> cdefs; + target->GetCompileDefinitions(cdefs, buildType); - if(!cdefs.empty()) + // Expand the list. + for(std::vector<std::string>::const_iterator di = cdefs.begin(); + di != cdefs.end(); ++di) { - // Expand the list. - std::vector<std::string> defs; - cmSystemTools::ExpandListArgument(cdefs.c_str(), defs); - for(std::vector<std::string>::const_iterator di = defs.begin(); - di != defs.end(); ++di) - { - cmXMLSafe safedef(di->c_str()); - fout <<" <Add option=\"-D" << safedef.str() << "\" />\n"; - } + cmXMLSafe safedef(di->c_str()); + fout <<" <Add option=\"-D" << safedef.str() << "\" />\n"; } // the include directories for this target diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 012013c..d925432 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -463,7 +463,7 @@ ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg, cmTarget *target, } // Add preprocessor definitions for this target and configuration. - lg->AppendDefines(defines, target->GetCompileDefinitions(config)); + lg->AddCompileDefinitions(defines, target, config); lg->AppendDefines(defines, source->GetProperty("COMPILE_DEFINITIONS")); { std::string defPropName = "COMPILE_DEFINITIONS_"; diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index 5daa47d..b44864e 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -62,15 +62,10 @@ void cmFindCommon::GenerateDocumentation() "The CMake variable CMAKE_FIND_ROOT_PATH specifies one or more " "directories to be prepended to all other search directories. " "This effectively \"re-roots\" the entire search under given locations. " - "By default it is empty. " - "The variable CMAKE_SYSROOT can also be used to specify exactly one " - "directory to use as a prefix. Setting CMAKE_SYSROOT also has other " - "effects. See the documentation for that variable for more. " - "These are especially useful when " + "By default it is empty. It is especially useful when " "cross-compiling to point to the root directory of the " "target environment and CMake will search there too. By default at first " - "the CMAKE_SYSROOT directory is searched, then the directories listed in " - "CMAKE_FIND_ROOT_PATH and then the non-rooted " + "the directories listed in CMAKE_FIND_ROOT_PATH and then the non-rooted " "directories will be searched. " "The default behavior can be adjusted by setting " "CMAKE_FIND_ROOT_PATH_MODE_XXX. This behavior can be manually " @@ -192,27 +187,16 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths) { return; } - const char* sysroot = - this->Makefile->GetDefinition("CMAKE_SYSROOT"); const char* rootPath = this->Makefile->GetDefinition("CMAKE_FIND_ROOT_PATH"); - const bool noSysroot = !sysroot || !*sysroot; - const bool noRootPath = !rootPath || !*rootPath; - if(noSysroot && noRootPath) + if((rootPath == 0) || (strlen(rootPath) == 0)) { return; } // Construct the list of path roots with no trailing slashes. std::vector<std::string> roots; - if (sysroot) - { - roots.push_back(sysroot); - } - if (rootPath) - { - cmSystemTools::ExpandListArgument(rootPath, roots); - } + cmSystemTools::ExpandListArgument(rootPath, roots); for(std::vector<std::string>::iterator ri = roots.begin(); ri != roots.end(); ++ri) { diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index 5b79e35..8b17c37 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -22,7 +22,7 @@ cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker( const GeneratorExpressionContent *content, cmGeneratorExpressionDAGChecker *parent) : Parent(parent), Target(target), Property(property), - Content(content), Backtrace(backtrace) + Content(content), Backtrace(backtrace), TransitivePropertiesOnly(false) { const cmGeneratorExpressionDAGChecker *top = this; const cmGeneratorExpressionDAGChecker *p = this->Parent; @@ -139,6 +139,20 @@ cmGeneratorExpressionDAGChecker::checkGraph() const } //---------------------------------------------------------------------------- +bool cmGeneratorExpressionDAGChecker::GetTransitivePropertiesOnly() +{ + const cmGeneratorExpressionDAGChecker *top = this; + const cmGeneratorExpressionDAGChecker *parent = this->Parent; + while (parent) + { + top = parent; + parent = parent->Parent; + } + + return top->TransitivePropertiesOnly; +} + +//---------------------------------------------------------------------------- bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries(const char *tgt) { const cmGeneratorExpressionDAGChecker *top = this; @@ -160,7 +174,8 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries(const char *tgt) || strcmp(prop, "LINK_INTERFACE_LIBRARIES") == 0 || strcmp(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES") == 0 || strncmp(prop, "LINK_INTERFACE_LIBRARIES_", 25) == 0 - || strncmp(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES_", 34) == 0); + || strncmp(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES_", 34) == 0) + || strcmp(prop, "INTERFACE_LINK_LIBRARIES") == 0; } //---------------------------------------------------------------------------- diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h index 95d466a..06b23f9 100644 --- a/Source/cmGeneratorExpressionDAGChecker.h +++ b/Source/cmGeneratorExpressionDAGChecker.h @@ -54,6 +54,10 @@ struct cmGeneratorExpressionDAGChecker CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(DECLARE_TRANSITIVE_PROPERTY_METHOD) + bool GetTransitivePropertiesOnly(); + void SetTransitivePropertiesOnly() + { this->TransitivePropertiesOnly = true; } + private: Result checkGraph() const; @@ -65,6 +69,7 @@ private: const GeneratorExpressionContent * const Content; const cmListFileBacktrace Backtrace; Result CheckResult; + bool TransitivePropertiesOnly; }; #endif diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 05bbc1c..2bdff78 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -492,6 +492,24 @@ static const struct VersionEqualNode : public cmGeneratorExpressionNode } versionEqualNode; //---------------------------------------------------------------------------- +static const struct LinkOnlyNode : public cmGeneratorExpressionNode +{ + LinkOnlyNode() {} + + std::string Evaluate(const std::vector<std::string> ¶meters, + cmGeneratorExpressionContext *, + const GeneratorExpressionContent *, + cmGeneratorExpressionDAGChecker *dagChecker) const + { + if(!dagChecker->GetTransitivePropertiesOnly()) + { + return parameters.front(); + } + return ""; + } +} linkOnlyNode; + +//---------------------------------------------------------------------------- static const struct ConfigurationNode : public cmGeneratorExpressionNode { ConfigurationNode() {} @@ -900,13 +918,14 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode if (std::find_if(transBegin, transEnd, TransitiveWhitelistCompare(propertyName)) != transEnd) { - const cmTarget::LinkInterface *iface = target->GetLinkInterface( - context->Config, - headTarget); - if(iface) + + std::vector<std::string> libs; + target->GetTransitivePropertyLinkLibraries(context->Config, + headTarget, libs); + if (!libs.empty()) { linkedTargetsContent = - getLinkedTargetsContent(iface->Libraries, target, + getLinkedTargetsContent(libs, target, headTarget, context, &dagChecker, interfacePropertyName); @@ -1014,10 +1033,13 @@ static const struct TargetNameNode : public cmGeneratorExpressionNode //---------------------------------------------------------------------------- static const char* targetPolicyWhitelist[] = { - "CMP0003" - , "CMP0004" - , "CMP0008" - , "CMP0020" + 0 +#define TARGET_POLICY_STRING(POLICY) \ + , #POLICY + + CM_FOR_EACH_TARGET_POLICY(TARGET_POLICY_STRING) + +#undef TARGET_POLICY_STRING }; cmPolicies::PolicyStatus statusForTarget(cmTarget *tgt, const char *policy) @@ -1028,10 +1050,7 @@ cmPolicies::PolicyStatus statusForTarget(cmTarget *tgt, const char *policy) return tgt->GetPolicyStatus ## POLICY (); \ } \ - RETURN_POLICY(CMP0003) - RETURN_POLICY(CMP0004) - RETURN_POLICY(CMP0008) - RETURN_POLICY(CMP0020) + CM_FOR_EACH_TARGET_POLICY(RETURN_POLICY) #undef RETURN_POLICY @@ -1047,10 +1066,7 @@ cmPolicies::PolicyID policyForString(const char *policy_id) return cmPolicies:: POLICY_ID; \ } \ - RETURN_POLICY_ID(CMP0003) - RETURN_POLICY_ID(CMP0004) - RETURN_POLICY_ID(CMP0008) - RETURN_POLICY_ID(CMP0020) + CM_FOR_EACH_TARGET_POLICY(RETURN_POLICY_ID) #undef RETURN_POLICY_ID @@ -1080,7 +1096,7 @@ static const struct TargetPolicyNode : public cmGeneratorExpressionNode context->HadContextSensitiveCondition = true; - for (size_t i = 0; + for (size_t i = 1; i < (sizeof(targetPolicyWhitelist) / sizeof(*targetPolicyWhitelist)); ++i) @@ -1106,8 +1122,17 @@ static const struct TargetPolicyNode : public cmGeneratorExpressionNode } reportError(context, content->GetOriginalExpression(), "$<TARGET_POLICY:prop> may only be used with a limited number of " - "policies. Currently it may be used with policies CMP0003, CMP0004, " - "CMP0008 and CMP0020." + "policies. Currently it may be used with the following policies:\n" + +#define STRINGIFY_HELPER(X) #X +#define STRINGIFY(X) STRINGIFY_HELPER(X) + +#define TARGET_POLICY_LIST_ITEM(POLICY) \ + " * " STRINGIFY(POLICY) "\n" + + CM_FOR_EACH_TARGET_POLICY(TARGET_POLICY_LIST_ITEM) + +#undef TARGET_POLICY_LIST_ITEM ); return std::string(); } @@ -1395,6 +1420,8 @@ cmGeneratorExpressionNode* GetNode(const std::string &identifier) return &installPrefixNode; else if (identifier == "JOIN") return &joinNode; + else if (identifier == "LINK_ONLY") + return &linkOnlyNode; return 0; } diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index ad74767..740420e 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -892,12 +892,28 @@ void cmGlobalGenerator::Configure() if ( this->CMakeInstance->GetWorkingMode() == cmake::NORMAL_MODE) { - const char* msg = "Configuring done"; + cmOStringStream msg; if(cmSystemTools::GetErrorOccuredFlag()) { - msg = "Configuring incomplete, errors occurred!"; + msg << "Configuring incomplete, errors occurred!"; + const char* logs[] = {"CMakeOutput.log", "CMakeError.log", 0}; + for(const char** log = logs; *log; ++log) + { + std::string f = this->CMakeInstance->GetHomeOutputDirectory(); + f += this->CMakeInstance->GetCMakeFilesDirectory(); + f += "/"; + f += *log; + if(cmSystemTools::FileExists(f.c_str())) + { + msg << "\nSee also \"" << f << "\"."; + } + } } - this->CMakeInstance->UpdateProgress(msg, -1); + else + { + msg << "Configuring done"; + } + this->CMakeInstance->UpdateProgress(msg.str().c_str(), -1); } } @@ -1121,8 +1137,9 @@ void cmGlobalGenerator::CreateGeneratorTargets() cmGeneratorTargetsType generatorTargets; cmMakefile *mf = this->LocalGenerators[i]->GetMakefile(); - const char *noconfig_compile_definitions = - mf->GetProperty("COMPILE_DEFINITIONS"); + + const std::vector<cmValueWithOrigin> noconfig_compile_definitions = + mf->GetCompileDefinitionsEntries(); std::vector<std::string> configs; mf->GetConfigurations(configs); @@ -1134,7 +1151,13 @@ void cmGlobalGenerator::CreateGeneratorTargets() cmTarget* t = &ti->second; { - t->AppendProperty("COMPILE_DEFINITIONS", noconfig_compile_definitions); + for (std::vector<cmValueWithOrigin>::const_iterator it + = noconfig_compile_definitions.begin(); + it != noconfig_compile_definitions.end(); ++it) + { + t->InsertCompileDefinition(*it); + } + for(std::vector<std::string>::const_iterator ci = configs.begin(); ci != configs.end(); ++ci) { diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 9cfbe42..63de1a5 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1741,8 +1741,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->AppendDefines(ppDefs, exportMacro); } cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); - this->AppendDefines(ppDefs, - target.GetCompileDefinitions(configName).c_str()); + std::vector<std::string> targetDefines; + target.GetCompileDefinitions(targetDefines, configName); + this->AppendDefines(ppDefs, targetDefines); buildSettings->AddAttribute ("GCC_PREPROCESSOR_DEFINITIONS", ppDefs.CreateList()); diff --git a/Source/cmIDEOptions.cxx b/Source/cmIDEOptions.cxx index 76a60cf..34a9c7c 100644 --- a/Source/cmIDEOptions.cxx +++ b/Source/cmIDEOptions.cxx @@ -165,6 +165,11 @@ void cmIDEOptions::AddDefines(const char* defines) cmSystemTools::ExpandListArgument(defines, this->Defines); } } +//---------------------------------------------------------------------------- +void cmIDEOptions::AddDefines(const std::vector<std::string> &defines) +{ + this->Defines.insert(this->Defines.end(), defines.begin(), defines.end()); +} //---------------------------------------------------------------------------- void cmIDEOptions::AddFlag(const char* flag, const char* value) diff --git a/Source/cmIDEOptions.h b/Source/cmIDEOptions.h index e556bde..e78af3e 100644 --- a/Source/cmIDEOptions.h +++ b/Source/cmIDEOptions.h @@ -27,6 +27,7 @@ public: // Store definitions and flags. void AddDefine(const std::string& define); void AddDefines(const char* defines); + void AddDefines(const std::vector<std::string> &defines); void AddFlag(const char* flag, const char* value); void RemoveFlag(const char* flag); const char* GetFlag(const char* flag); diff --git a/Source/cmIncludeCommand.h b/Source/cmIncludeCommand.h index c46c02d..d97b7c3 100644 --- a/Source/cmIncludeCommand.h +++ b/Source/cmIncludeCommand.h @@ -55,7 +55,7 @@ public: */ virtual const char* GetTerseDocumentation() const { - return "Read CMake listfile code from the given file."; + return "Load and run CMake code from a file or module."; } /** @@ -66,9 +66,10 @@ public: return " include(<file|module> [OPTIONAL] [RESULT_VARIABLE <VAR>]\n" " [NO_POLICY_SCOPE])\n" - "Reads CMake listfile code from the given file. Commands in the file " - "are processed immediately as if they were written in place of the " - "include command. If OPTIONAL is present, then no error " + "Load and run CMake code from the file given. " + "Variable reads and writes access the scope of the caller " + "(dynamic scoping). " + "If OPTIONAL is present, then no error " "is raised if the file does not exist. If RESULT_VARIABLE is given " "the variable will be set to the full filename which " "has been included or NOTFOUND if it failed.\n" diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index dcd418b..d3a8037 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -1196,6 +1196,8 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args) cmInstallCommandArguments ica(this->DefaultComponentName); cmCAString exp(&ica.Parser, "EXPORT"); cmCAString name_space(&ica.Parser, "NAMESPACE", &ica.ArgumentGroup); + cmCAEnabler exportOld(&ica.Parser, "EXPORT_LINK_INTERFACE_LIBRARIES", + &ica.ArgumentGroup); cmCAString filename(&ica.Parser, "FILE", &ica.ArgumentGroup); exp.Follows(0); @@ -1268,15 +1270,40 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args) } } + cmExportSet *exportSet = this->Makefile->GetLocalGenerator() + ->GetGlobalGenerator()->GetExportSets()[exp.GetString()]; + if (exportOld.IsEnabled()) + { + for(std::vector<cmTargetExport*>::const_iterator + tei = exportSet->GetTargetExports()->begin(); + tei != exportSet->GetTargetExports()->end(); ++tei) + { + cmTargetExport const* te = *tei; + const bool newCMP0022Behavior = + te->Target->GetPolicyStatusCMP0022() != cmPolicies::WARN + && te->Target->GetPolicyStatusCMP0022() != cmPolicies::OLD; + + if(!newCMP0022Behavior) + { + cmOStringStream e; + e << "INSTALL(EXPORT) given keyword \"" + << "EXPORT_LINK_INTERFACE_LIBRARIES" << "\", but target \"" + << te->Target->GetName() + << "\" does not have policy CMP0022 set to NEW."; + this->SetError(e.str().c_str()); + return false; + } + } + } + // Create the export install generator. cmInstallExportGenerator* exportGenerator = new cmInstallExportGenerator( - this->Makefile->GetLocalGenerator() - ->GetGlobalGenerator()->GetExportSets()[exp.GetString()], + exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(), ica.GetConfigurations(), ica.GetComponent().c_str(), fname.c_str(), - name_space.GetCString(), this->Makefile); + name_space.GetCString(), exportOld.IsEnabled(), this->Makefile); this->Makefile->AddInstallGenerator(exportGenerator); return true; diff --git a/Source/cmInstallCommand.h b/Source/cmInstallCommand.h index 7c06009..39acd23 100644 --- a/Source/cmInstallCommand.h +++ b/Source/cmInstallCommand.h @@ -291,6 +291,7 @@ public: " [NAMESPACE <namespace>] [FILE <name>.cmake]\n" " [PERMISSIONS permissions...]\n" " [CONFIGURATIONS [Debug|Release|...]]\n" + " [EXPORT_LINK_INTERFACE_LIBRARIES]\n" " [COMPONENT <component>])\n" "The EXPORT form generates and installs a CMake file containing code " "to import targets from the installation tree into another project. " @@ -306,6 +307,10 @@ public: "installed when one of the named configurations is installed. " "Additionally, the generated import file will reference only the " "matching target configurations. " + "The EXPORT_LINK_INTERFACE_LIBRARIES keyword, if present, causes the " + "contents of the properties matching " + "(IMPORTED_)?LINK_INTERFACE_LIBRARIES(_<CONFIG>)? to be exported, when " + "policy CMP0022 is NEW. " "If a COMPONENT option is specified that does not match that given " "to the targets associated with <export-name> the behavior is " "undefined. " diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index 0a645a8..3e9e6ac 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -33,12 +33,14 @@ cmInstallExportGenerator::cmInstallExportGenerator( std::vector<std::string> const& configurations, const char* component, const char* filename, const char* name_space, + bool exportOld, cmMakefile* mf) :cmInstallGenerator(destination, configurations, component) ,ExportSet(exportSet) ,FilePermissions(file_permissions) ,FileName(filename) ,Namespace(name_space) + ,ExportOld(exportOld) ,Makefile(mf) { this->EFGen = new cmExportInstallFileGenerator(this); @@ -137,6 +139,7 @@ void cmInstallExportGenerator::GenerateScript(std::ostream& os) // Generate the import file for this export set. this->EFGen->SetExportFile(this->MainImportFile.c_str()); this->EFGen->SetNamespace(this->Namespace.c_str()); + this->EFGen->SetExportOld(this->ExportOld); if(this->ConfigurationTypes->empty()) { if(this->ConfigurationName && *this->ConfigurationName) diff --git a/Source/cmInstallExportGenerator.h b/Source/cmInstallExportGenerator.h index 7aff731..37b5593 100644 --- a/Source/cmInstallExportGenerator.h +++ b/Source/cmInstallExportGenerator.h @@ -31,7 +31,7 @@ public: const std::vector<std::string>& configurations, const char* component, const char* filename, const char* name_space, - cmMakefile* mf); + bool exportOld, cmMakefile* mf); ~cmInstallExportGenerator(); cmExportSet* GetExportSet() {return this->ExportSet;} @@ -52,6 +52,7 @@ protected: std::string FilePermissions; std::string FileName; std::string Namespace; + bool ExportOld; cmMakefile* Makefile; std::string TempDir; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 00846d5..d55a305 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1339,6 +1339,17 @@ std::string cmLocalGenerator::GetIncludeFlags( } //---------------------------------------------------------------------------- +void cmLocalGenerator::AddCompileDefinitions(std::set<std::string>& defines, + cmTarget* target, + const char* config) +{ + std::vector<std::string> targetDefines; + target->GetCompileDefinitions(targetDefines, + config); + this->AppendDefines(defines, targetDefines); +} + +//---------------------------------------------------------------------------- void cmLocalGenerator::AddCompileOptions( std::string& flags, cmTarget* target, const char* lang, const char* config @@ -1467,8 +1478,6 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, return; } - std::string rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT"); - std::vector<std::string> implicitDirs; // Load implicit include directories for this language. std::string impDirVar = "CMAKE_"; @@ -1481,9 +1490,7 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, for(std::vector<std::string>::const_iterator i = impDirVec.begin(); i != impDirVec.end(); ++i) { - std::string d = rootPath + *i; - cmSystemTools::ConvertToUnixSlashes(d); - emitted.insert(d); + emitted.insert(*i); if (!stripImplicitInclDirs) { implicitDirs.push_back(*i); @@ -2301,7 +2308,13 @@ void cmLocalGenerator::AppendDefines(std::set<std::string>& defines, // Expand the list of definitions. std::vector<std::string> defines_vec; cmSystemTools::ExpandListArgument(defines_list, defines_vec); + this->AppendDefines(defines, defines_vec); +} +//---------------------------------------------------------------------------- +void cmLocalGenerator::AppendDefines(std::set<std::string>& defines, + const std::vector<std::string> &defines_vec) +{ for(std::vector<std::string>::const_iterator di = defines_vec.begin(); di != defines_vec.end(); ++di) { diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index f35ef8e..5c644d1 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -166,6 +166,9 @@ public: { this->AppendDefines(defines, defines_list.c_str()); } + void AppendDefines(std::set<std::string>& defines, + const std::vector<std::string> &defines_vec); + /** * Join a set of defines into a definesString with a space separator. */ @@ -220,6 +223,8 @@ public: bool stripImplicitInclDirs = true); void AddCompileOptions(std::string& flags, cmTarget* target, const char* lang, const char* config); + void AddCompileDefinitions(std::set<std::string>& defines, cmTarget* target, + const char* config); /** Compute the language used to compile the given source file. */ const char* GetSourceFileLanguage(const cmSourceFile& source); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 78a70f8..1d1acfd 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1962,8 +1962,8 @@ void cmLocalUnixMakefileGenerator3 // Build a list of preprocessor definitions for the target. std::set<std::string> defines; - this->AppendDefines(defines, target.GetCompileDefinitions( - this->ConfigurationName.c_str())); + this->AddCompileDefinitions(defines, &target, + this->ConfigurationName.c_str()); if(!defines.empty()) { cmakefileStream diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 0b61e1d..df6e1f1 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1701,21 +1701,11 @@ void cmLocalVisualStudio6Generator std::set<std::string> minsizeDefinesSet; std::set<std::string> debugrelDefinesSet; - this->AppendDefines( - definesSet, - target.GetCompileDefinitions(0)); - this->AppendDefines( - debugDefinesSet, - target.GetCompileDefinitions("DEBUG")); - this->AppendDefines( - releaseDefinesSet, - target.GetCompileDefinitions("RELEASE")); - this->AppendDefines( - minsizeDefinesSet, - target.GetCompileDefinitions("MINSIZEREL")); - this->AppendDefines( - debugrelDefinesSet, - target.GetCompileDefinitions("RELWITHDEBINFO")); + this->AddCompileDefinitions(definesSet, &target, 0); + this->AddCompileDefinitions(debugDefinesSet, &target, "DEBUG"); + this->AddCompileDefinitions(releaseDefinesSet, &target, "RELEASE"); + this->AddCompileDefinitions(minsizeDefinesSet, &target, "MINSIZEREL"); + this->AddCompileDefinitions(debugrelDefinesSet, &target, "RELWITHDEBINFO"); std::string defines = " "; std::string debugDefines = " "; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 1d2f709..9ecd53d 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -746,7 +746,9 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, targetOptions.ParseFinish(); cmGeneratorTarget* gt = this->GlobalGenerator->GetGeneratorTarget(&target); - targetOptions.AddDefines(target.GetCompileDefinitions(configName).c_str()); + std::vector<std::string> targetDefines; + target.GetCompileDefinitions(targetDefines, configName); + targetOptions.AddDefines(targetDefines); targetOptions.SetVerboseMakefile( this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index f3a66ba..d94c93d 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1505,6 +1505,12 @@ void cmMakefile::InitializeFromParent() parentOptions.begin(), parentOptions.end()); + const std::vector<cmValueWithOrigin> parentDefines = + parent->GetCompileDefinitionsEntries(); + this->CompileDefinitionsEntries.insert(this->CompileDefinitionsEntries.end(), + parentDefines.begin(), + parentDefines.end()); + this->SystemIncludeDirectories = parent->SystemIncludeDirectories; // define flags @@ -3493,6 +3499,19 @@ void cmMakefile::SetProperty(const char* prop, const char* value) this->CompileOptionsEntries.push_back(cmValueWithOrigin(value, lfbt)); return; } + if (propname == "COMPILE_DEFINITIONS") + { + this->CompileDefinitionsEntries.clear(); + if (!value) + { + return; + } + cmListFileBacktrace lfbt; + this->GetBacktrace(lfbt); + cmValueWithOrigin entry(value, lfbt); + this->CompileDefinitionsEntries.push_back(entry); + return; + } if ( propname == "INCLUDE_REGULAR_EXPRESSION" ) { @@ -3540,6 +3559,14 @@ void cmMakefile::AppendProperty(const char* prop, const char* value, cmValueWithOrigin(value, lfbt)); return; } + if (propname == "COMPILE_DEFINITIONS") + { + cmListFileBacktrace lfbt; + this->GetBacktrace(lfbt); + this->CompileDefinitionsEntries.push_back( + cmValueWithOrigin(value, lfbt)); + return; + } if ( propname == "LINK_DIRECTORIES" ) { std::vector<std::string> varArgsExpanded; @@ -3679,6 +3706,20 @@ const char *cmMakefile::GetProperty(const char* prop, } return output.c_str(); } + else if (!strcmp("COMPILE_DEFINITIONS",prop)) + { + std::string sep; + for (std::vector<cmValueWithOrigin>::const_iterator + it = this->CompileDefinitionsEntries.begin(), + end = this->CompileDefinitionsEntries.end(); + it != end; ++it) + { + output += sep; + output += it->Value; + sep = ";"; + } + return output.c_str(); + } bool chain = false; const char *retVal = diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 4297155..1b10773 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -871,6 +871,10 @@ public: { return this->CompileOptionsEntries; } + std::vector<cmValueWithOrigin> GetCompileDefinitionsEntries() const + { + return this->CompileDefinitionsEntries; + } bool IsGeneratingBuildSystem(){ return this->GeneratingBuildSystem; } void SetGeneratingBuildSystem(){ this->GeneratingBuildSystem = true; } @@ -925,6 +929,7 @@ protected: std::vector<cmValueWithOrigin> IncludeDirectoriesEntries; std::vector<cmValueWithOrigin> CompileOptionsEntries; + std::vector<cmValueWithOrigin> CompileDefinitionsEntries; // Track the value of the computed DEFINITIONS property. void AddDefineFlag(const char*, std::string&); diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 271183e..e4219a9 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -365,22 +365,6 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) vars.TargetVersionMajor = targetVersionMajor.c_str(); vars.TargetVersionMinor = targetVersionMinor.c_str(); - if (const char *rootPath = - this->Makefile->GetDefinition("CMAKE_SYSROOT")) - { - if (*rootPath) - { - if (const char *sysrootFlag = - this->Makefile->GetDefinition("CMAKE_SYSROOT_FLAG")) - { - flags += " "; - flags += sysrootFlag; - flags += this->LocalGenerator->EscapeForShell(rootPath); - flags += " "; - } - } - } - vars.LinkLibraries = linkLibs.c_str(); vars.Flags = flags.c_str(); vars.LinkFlags = linkFlags.c_str(); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 36d1a5a..347f26d 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -589,26 +589,6 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules cmLocalGenerator::SHELL); vars.ObjectDir = objdir.c_str(); vars.Target = targetOutPathReal.c_str(); - - if(this->Target->GetType() == cmTarget::SHARED_LIBRARY) - { - if (const char *rootPath = - this->Makefile->GetSafeDefinition("CMAKE_SYSROOT")) - { - if (*rootPath) - { - if (const char *sysrootFlag = - this->Makefile->GetDefinition("CMAKE_SYSROOT_FLAG")) - { - linkFlags += " "; - linkFlags += sysrootFlag; - linkFlags += this->LocalGenerator->EscapeForShell(rootPath); - linkFlags += " "; - } - } - } - } - vars.LinkLibraries = linkLibs.c_str(); vars.ObjectsQuoted = buildObjs.c_str(); if (this->Target->HasSOName(this->ConfigName)) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 1492dfa..2ee236c 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -309,9 +309,8 @@ std::string cmMakefileTargetGenerator::GetDefines(const std::string &l) } // Add preprocessor definitions for this target and configuration. - this->LocalGenerator->AppendDefines - (defines, this->Target->GetCompileDefinitions( - this->LocalGenerator->ConfigurationName.c_str())); + this->LocalGenerator->AddCompileDefinitions(defines, this->Target, + this->LocalGenerator->ConfigurationName.c_str()); std::string definesString; this->LocalGenerator->JoinDefines(defines, definesString, lang); @@ -644,23 +643,6 @@ cmMakefileTargetGenerator cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); vars.ObjectDir = objectDir.c_str(); - - if (const char *rootPath = - this->Makefile->GetSafeDefinition("CMAKE_SYSROOT")) - { - if (*rootPath) - { - if (const char *sysrootFlag = - this->Makefile->GetDefinition("CMAKE_SYSROOT_FLAG")) - { - flags += " "; - flags += sysrootFlag; - flags += this->LocalGenerator->EscapeForShell(rootPath); - flags += " "; - } - } - } - vars.Flags = flags.c_str(); std::string definesString = "$("; diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 921ca92..fa7e396 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -224,27 +224,7 @@ cmNinjaNormalTargetGenerator vars.TargetVersionMajor = targetVersionMajor.c_str(); vars.TargetVersionMinor = targetVersionMinor.c_str(); - - std::string flags = "$FLAGS"; - - if (const char *rootPath = - this->GetMakefile()->GetSafeDefinition("CMAKE_SYSROOT")) - { - if (*rootPath) - { - if (const char *sysrootFlag = - this->GetMakefile()->GetDefinition("CMAKE_SYSROOT_FLAG")) - { - flags += " "; - flags += sysrootFlag; - flags += this->GetLocalGenerator()->EscapeForShell(rootPath); - flags += " "; - } - } - } - - vars.Flags = flags.c_str(); - + vars.Flags = "$FLAGS"; vars.LinkFlags = "$LINK_FLAGS"; std::string langFlags; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 65173ca..1179224 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -201,9 +201,8 @@ ComputeDefines(cmSourceFile *source, const std::string& language) } // Add preprocessor definitions for this target and configuration. - this->LocalGenerator->AppendDefines - (defines, - this->Target->GetCompileDefinitions(this->GetConfigName())); + this->LocalGenerator->AddCompileDefinitions(defines, this->Target, + this->GetConfigName()); this->LocalGenerator->AppendDefines (defines, source->GetProperty("COMPILE_DEFINITIONS")); @@ -384,23 +383,7 @@ cmNinjaTargetGenerator cmSystemTools::ReplaceString(depFlagsStr, "<CMAKE_C_COMPILER>", mf->GetDefinition("CMAKE_C_COMPILER")); flags += " " + depFlagsStr; - - if (const char *rootPath = - this->Makefile->GetSafeDefinition("CMAKE_SYSROOT")) - { - if (*rootPath) - { - if (const char *sysrootFlag = - this->Makefile->GetDefinition("CMAKE_SYSROOT_FLAG")) - { - flags += " "; - flags += sysrootFlag; - flags += this->LocalGenerator->EscapeForShell(rootPath); - flags += " "; - } - } - } - } + } vars.Flags = flags.c_str(); diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 32829a6..70c28d4 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -544,6 +544,37 @@ cmPolicies::cmPolicies() "The NEW behavior for this policy is to issue a FATAL_ERROR if " "INCLUDE_DIRECTORIES contains a relative path.", 2,8,11,20130516, cmPolicies::WARN); + + this->DefinePolicy( + CMP0022, "CMP0022", + "INTERFACE_LINK_LIBRARIES defines the link interface.", + "CMake 2.8.11 constructed the 'link interface' of a target from " + "properties matching (IMPORTED_)?LINK_INTERFACE_LIBRARIES(_<CONFIG>)?. " + "The modern way to specify config-sensitive content is to use generator " + "expressions and the IMPORTED_ prefix makes uniform processing of the " + "link interface with generator expressions impossible. The " + "INTERFACE_LINK_LIBRARIES target property was introduced as a " + "replacement in CMake 2.8.12. This new property is named consistently " + "with the INTERFACE_COMPILE_DEFINITIONS, INTERFACE_INCLUDE_DIRECTORIES " + "and INTERFACE_COMPILE_OPTIONS properties. For in-build targets, CMake " + "will use the INTERFACE_LINK_LIBRARIES property as the source of the " + "link interface only if policy CMP0022 is NEW. " + "When exporting a target which has this policy set to NEW, only the " + "INTERFACE_LINK_LIBRARIES property will be processed and generated for " + "the IMPORTED target by default. A new option to the install(EXPORT) " + "and export commands allows export of the old-style properties for " + "compatibility with downstream users of CMake versions older than " + "2.8.12. " + "The target_link_libraries command will no longer populate the " + "properties matching LINK_INTERFACE_LIBRARIES(_<CONFIG>)? if this policy " + "is NEW." + "\n" + "The OLD behavior for this policy is to ignore the " + "INTERFACE_LINK_LIBRARIES property for in-build targets. " + "The NEW behavior for this policy is to use the INTERFACE_LINK_LIBRARIES " + "property for in-build targets, and ignore the old properties matching " + "(IMPORTED_)?LINK_INTERFACE_LIBRARIES(_<CONFIG>)?.", + 2,8,11,20130516, cmPolicies::WARN); } cmPolicies::~cmPolicies() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index a033e87..20c953f 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -72,6 +72,7 @@ public: CMP0020, ///< Automatically link Qt executables to qtmain target CMP0021, ///< Fatal error on relative paths in INCLUDE_DIRECTORIES /// target property + CMP0022, ///< INTERFACE_LINK_LIBRARIES defines the link interface /** \brief Always the last entry. * diff --git a/Source/cmProjectCommand.h b/Source/cmProjectCommand.h index a53cb3f..9547c4c 100644 --- a/Source/cmProjectCommand.h +++ b/Source/cmProjectCommand.h @@ -71,7 +71,13 @@ public: "language \"NONE\" all checks for any language can be disabled. " "If a variable exists called CMAKE_PROJECT_<projectName>_INCLUDE, " "the file pointed to by that variable will be included as the last step " - "of the project command."; + "of the project command." + "\n" + "The top-level CMakeLists.txt file for a project must contain a " + "literal, direct call to the project() command; loading one through " + "the include() command is not sufficient. " + "If no such call exists CMake will implicitly add one to the top that " + "enables the default languages (C and CXX)."; } cmTypeMacro(cmProjectCommand, cmCommand); diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index 34b3c7e..93e39ab 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -175,15 +175,17 @@ static void GetCompileDefinitionsAndDirectories(cmTarget *target, incs += *incDirIt; } - defs = target->GetCompileDefinitions(config); + std::set<std::string> defines; + localGen->AddCompileDefinitions(defines, target, config); - const char *tmp = makefile->GetProperty("COMPILE_DEFINITIONS"); sep = ""; - if (tmp) + for(std::set<std::string>::const_iterator defIt = defines.begin(); + defIt != defines.end(); + ++defIt) { defs += sep; sep = ";"; - defs += tmp; + defs += *defIt; } } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index a90fa74..19a8edf 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -141,13 +141,15 @@ public: }; std::vector<TargetPropertyEntry*> IncludeDirectoriesEntries; std::vector<TargetPropertyEntry*> CompileOptionsEntries; + std::vector<TargetPropertyEntry*> CompileDefinitionsEntries; std::vector<cmValueWithOrigin> LinkInterfacePropertyEntries; std::map<std::string, std::vector<TargetPropertyEntry*> > CachedLinkInterfaceIncludeDirectoriesEntries; std::map<std::string, std::vector<TargetPropertyEntry*> > CachedLinkInterfaceCompileOptionsEntries; - std::map<std::string, std::string> CachedLinkInterfaceCompileDefinitions; + std::map<std::string, std::vector<TargetPropertyEntry*> > + CachedLinkInterfaceCompileDefinitionsEntries; std::map<std::string, bool> CacheLinkInterfaceIncludeDirectoriesDone; std::map<std::string, bool> CacheLinkInterfaceCompileDefinitionsDone; @@ -186,17 +188,20 @@ cmTargetInternals::~cmTargetInternals() { deleteAndClear(this->CachedLinkInterfaceIncludeDirectoriesEntries); deleteAndClear(this->CachedLinkInterfaceCompileOptionsEntries); + deleteAndClear(this->CachedLinkInterfaceCompileDefinitionsEntries); } //---------------------------------------------------------------------------- cmTarget::cmTarget() { +#define INITIALIZE_TARGET_POLICY_MEMBER(POLICY) \ + this->PolicyStatus ## POLICY = cmPolicies::WARN; + + CM_FOR_EACH_TARGET_POLICY(INITIALIZE_TARGET_POLICY_MEMBER) + +#undef INITIALIZE_TARGET_POLICY_MEMBER + this->Makefile = 0; - this->PolicyStatusCMP0003 = cmPolicies::WARN; - this->PolicyStatusCMP0004 = cmPolicies::WARN; - this->PolicyStatusCMP0008 = cmPolicies::WARN; - this->PolicyStatusCMP0020 = cmPolicies::WARN; - this->PolicyStatusCMP0021 = cmPolicies::WARN; this->LinkLibrariesAnalyzed = false; this->HaveInstallRule = false; this->DLLPlatform = false; @@ -205,6 +210,7 @@ cmTarget::cmTarget() this->BuildInterfaceIncludesAppended = false; this->DebugIncludesDone = false; this->DebugCompileOptionsDone = false; + this->DebugCompileDefinitionsDone = false; } //---------------------------------------------------------------------------- @@ -474,7 +480,7 @@ void cmTarget::DefineProperties(cmake *cm) "imported library. " "The list " "should be disjoint from the list of interface libraries in the " - "IMPORTED_LINK_INTERFACE_LIBRARIES property. On platforms requiring " + "INTERFACE_LINK_LIBRARIES property. On platforms requiring " "dependent shared libraries to be found at link time CMake uses this " "list to add appropriate files or paths to the link command line. " "Ignored for non-imported targets."); @@ -495,7 +501,10 @@ void cmTarget::DefineProperties(cmake *cm) "The libraries will be included on the link line for the target. " "Unlike the LINK_INTERFACE_LIBRARIES property, this property applies " "to all imported target types, including STATIC libraries. " - "This property is ignored for non-imported targets."); + "This property is ignored for non-imported targets.\n" + "This property is ignored if the target also has a non-empty " + "INTERFACE_LINK_LIBRARIES property.\n" + "This property is deprecated. Use INTERFACE_LINK_LIBRARIES instead."); cm->DefineProperty ("IMPORTED_LINK_INTERFACE_LIBRARIES_<CONFIG>", cmProperty::TARGET, @@ -503,7 +512,10 @@ void cmTarget::DefineProperties(cmake *cm) "Configuration names correspond to those provided by the project " "from which the target is imported. " "If set, this property completely overrides the generic property " - "for the named configuration."); + "for the named configuration.\n" + "This property is ignored if the target also has a non-empty " + "INTERFACE_LINK_LIBRARIES property.\n" + "This property is deprecated. Use INTERFACE_LINK_LIBRARIES instead."); cm->DefineProperty ("IMPORTED_LINK_INTERFACE_LANGUAGES", cmProperty::TARGET, @@ -820,7 +832,10 @@ void cmTarget::DefineProperties(cmake *cm) "This property is initialized by the value of the variable " "CMAKE_LINK_INTERFACE_LIBRARIES if it is set when a target is " "created. " - "This property is ignored for STATIC libraries."); + "This property is ignored for STATIC libraries.\n" + "This property is overriden by the INTERFACE_LINK_LIBRARIES property if " + "policy CMP0022 is NEW.\n" + "This property is deprecated. Use INTERFACE_LINK_LIBRARIES instead."); cm->DefineProperty ("LINK_INTERFACE_LIBRARIES_<CONFIG>", cmProperty::TARGET, @@ -828,7 +843,23 @@ void cmTarget::DefineProperties(cmake *cm) "This is the configuration-specific version of " "LINK_INTERFACE_LIBRARIES. " "If set, this property completely overrides the generic property " - "for the named configuration."); + "for the named configuration.\n" + "This property is overriden by the INTERFACE_LINK_LIBRARIES property if " + "policy CMP0022 is NEW.\n" + "This property is deprecated. Use INTERFACE_LINK_LIBRARIES instead."); + + cm->DefineProperty + ("INTERFACE_LINK_LIBRARIES", cmProperty::TARGET, + "List public interface libraries for a shared library or executable.", + "This property contains the list of transitive link dependencies. " + "When the target is linked into another target the libraries " + "listed (and recursively their link interface libraries) will be " + "provided to the other target also. " + "This property is overriden by the LINK_INTERFACE_LIBRARIES or " + "LINK_INTERFACE_LIBRARIES_<CONFIG> property if " + "policy CMP0022 is OLD or unset.\n" + "\n" + CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS); cm->DefineProperty ("INTERFACE_INCLUDE_DIRECTORIES", cmProperty::TARGET, @@ -1668,16 +1699,13 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->SetPropertyDefault("POSITION_INDEPENDENT_CODE", 0); // Record current policies for later use. - this->PolicyStatusCMP0003 = - this->Makefile->GetPolicyStatus(cmPolicies::CMP0003); - this->PolicyStatusCMP0004 = - this->Makefile->GetPolicyStatus(cmPolicies::CMP0004); - this->PolicyStatusCMP0008 = - this->Makefile->GetPolicyStatus(cmPolicies::CMP0008); - this->PolicyStatusCMP0020 = - this->Makefile->GetPolicyStatus(cmPolicies::CMP0020); - this->PolicyStatusCMP0021 = - this->Makefile->GetPolicyStatus(cmPolicies::CMP0021); +#define CAPTURE_TARGET_POLICY(POLICY) \ + this->PolicyStatus ## POLICY = \ + this->Makefile->GetPolicyStatus(cmPolicies::POLICY); + + CM_FOR_EACH_TARGET_POLICY(CAPTURE_TARGET_POLICY) + +#undef CAPTURE_TARGET_POLICY } //---------------------------------------------------------------------------- @@ -2293,6 +2321,14 @@ void cmTarget::MergeLinkLibraries( cmMakefile& mf, { // We call this so that the dependencies get written to the cache this->AddLinkLibrary( mf, selfname, i->first.c_str(), i->second ); + + if (this->GetType() == cmTarget::STATIC_LIBRARY) + { + this->AppendProperty("INTERFACE_LINK_LIBRARIES", + ("$<LINK_ONLY:" + + this->GetDebugGeneratorExpressions(i->first.c_str(), i->second) + + ">").c_str()); + } } this->PrevLinkedLibraries = libs; } @@ -2845,6 +2881,17 @@ void cmTarget::SetProperty(const char* prop, const char* value) new cmTargetInternals::TargetPropertyEntry(cge)); return; } + if(strcmp(prop,"COMPILE_DEFINITIONS") == 0) + { + cmListFileBacktrace lfbt; + this->Makefile->GetBacktrace(lfbt); + cmGeneratorExpression ge(lfbt); + deleteAndClear(this->Internal->CompileDefinitionsEntries); + cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value); + this->Internal->CompileDefinitionsEntries.push_back( + new cmTargetInternals::TargetPropertyEntry(cge)); + return; + } if(strcmp(prop,"EXPORT_NAME") == 0 && this->IsImported()) { cmOStringStream e; @@ -2896,6 +2943,15 @@ void cmTarget::AppendProperty(const char* prop, const char* value, new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); return; } + if(strcmp(prop,"COMPILE_DEFINITIONS") == 0) + { + cmListFileBacktrace lfbt; + this->Makefile->GetBacktrace(lfbt); + cmGeneratorExpression ge(lfbt); + this->Internal->CompileDefinitionsEntries.push_back( + new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); + return; + } if(strcmp(prop,"EXPORT_NAME") == 0 && this->IsImported()) { cmOStringStream e; @@ -3000,6 +3056,20 @@ void cmTarget::InsertCompileOption(const cmValueWithOrigin &entry, } //---------------------------------------------------------------------------- +void cmTarget::InsertCompileDefinition(const cmValueWithOrigin &entry, + bool before) +{ + cmGeneratorExpression ge(entry.Backtrace); + + std::vector<cmTargetInternals::TargetPropertyEntry*>::iterator position + = before ? this->Internal->CompileDefinitionsEntries.begin() + : this->Internal->CompileDefinitionsEntries.end(); + + this->Internal->CompileDefinitionsEntries.insert(position, + new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry.Value))); +} + +//---------------------------------------------------------------------------- static void processIncludeDirectories(cmTarget *tgt, const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries, std::vector<std::string> &includes, @@ -3231,12 +3301,12 @@ std::vector<std::string> cmTarget::GetIncludeDirectories(const char *config) } //---------------------------------------------------------------------------- -static void processCompileOptions(cmTarget *tgt, +static void processCompileOptionsInternal(cmTarget *tgt, const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries, std::vector<std::string> &options, std::set<std::string> &uniqueOptions, cmGeneratorExpressionDAGChecker *dagChecker, - const char *config, bool debugOptions) + const char *config, bool debugOptions, const char *logName) { cmMakefile *mf = tgt->GetMakefile(); @@ -3281,7 +3351,8 @@ static void processCompileOptions(cmTarget *tgt, if (!usedOptions.empty()) { mf->GetCMakeInstance()->IssueMessage(cmake::LOG, - std::string("Used compile options for target ") + std::string("Used compile ") + logName + + std::string(" for target ") + tgt->GetName() + ":\n" + usedOptions, (*it)->ge->GetBacktrace()); } @@ -3289,6 +3360,18 @@ static void processCompileOptions(cmTarget *tgt, } //---------------------------------------------------------------------------- +static void processCompileOptions(cmTarget *tgt, + const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries, + std::vector<std::string> &options, + std::set<std::string> &uniqueOptions, + cmGeneratorExpressionDAGChecker *dagChecker, + const char *config, bool debugOptions) +{ + processCompileOptionsInternal(tgt, entries, options, uniqueOptions, + dagChecker, config, debugOptions, "options"); +} + +//---------------------------------------------------------------------------- void cmTarget::GetCompileOptions(std::vector<std::string> &result, const char *config) { @@ -3384,90 +3467,128 @@ void cmTarget::GetCompileOptions(std::vector<std::string> &result, } //---------------------------------------------------------------------------- -std::string cmTarget::GetCompileDefinitions(const char *config) +static void processCompileDefinitions(cmTarget *tgt, + const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries, + std::vector<std::string> &options, + std::set<std::string> &uniqueOptions, + cmGeneratorExpressionDAGChecker *dagChecker, + const char *config, bool debugOptions) { - const char *configProp = 0; - if (config) - { - std::string configPropName; - configPropName = "COMPILE_DEFINITIONS_" + cmSystemTools::UpperCase(config); - configProp = this->GetProperty(configPropName.c_str()); - } + processCompileOptionsInternal(tgt, entries, options, uniqueOptions, + dagChecker, config, debugOptions, + "definitions"); +} - const char *noconfigProp = this->GetProperty("COMPILE_DEFINITIONS"); +//---------------------------------------------------------------------------- +void cmTarget::GetCompileDefinitions(std::vector<std::string> &list, + const char *config) +{ + std::set<std::string> uniqueOptions; cmListFileBacktrace lfbt; + cmGeneratorExpressionDAGChecker dagChecker(lfbt, - this->GetName(), - "COMPILE_DEFINITIONS", 0, 0); + this->GetName(), + "COMPILE_DEFINITIONS", 0, 0); - std::string defsString = (noconfigProp ? noconfigProp : ""); - if (configProp && noconfigProp) + std::vector<std::string> debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) { - defsString += ";"; + cmSystemTools::ExpandListArgument(debugProp, debugProperties); } - defsString += (configProp ? configProp : ""); - - cmGeneratorExpression ge(lfbt); - std::string result = ge.Parse(defsString.c_str())->Evaluate(this->Makefile, - config, - false, - this, - &dagChecker); - std::vector<std::string> libs; - this->GetDirectLinkLibraries(config, libs, this); + bool debugDefines = !this->DebugCompileDefinitionsDone + && std::find(debugProperties.begin(), + debugProperties.end(), + "COMPILE_DEFINITIONS") + != debugProperties.end(); - if (libs.empty()) + if (this->Makefile->IsGeneratingBuildSystem()) { - return result; + this->DebugCompileDefinitionsDone = true; } - std::string sep; - std::string depString; - for (std::vector<std::string>::const_iterator it = libs.begin(); - it != libs.end(); ++it) - { - if ((cmGeneratorExpression::IsValidTargetName(it->c_str()) - || cmGeneratorExpression::Find(it->c_str()) != std::string::npos) - && this->Makefile->FindTargetToUse(it->c_str())) - { - depString += sep + "$<TARGET_PROPERTY:" - + *it + ",INTERFACE_COMPILE_DEFINITIONS>"; - sep = ";"; - } - } + processCompileDefinitions(this, + this->Internal->CompileDefinitionsEntries, + list, + uniqueOptions, + &dagChecker, + config, + debugDefines); std::string configString = config ? config : ""; if (!this->Internal->CacheLinkInterfaceCompileDefinitionsDone[configString]) { - cmGeneratorExpression ge2(lfbt); - cmsys::auto_ptr<cmCompiledGeneratorExpression> cge2 = - ge2.Parse(depString); - this->Internal->CachedLinkInterfaceCompileDefinitions[configString] = - cge2->Evaluate(this->Makefile, - config, - false, - this, - &dagChecker); - } - if (!this->Internal->CachedLinkInterfaceCompileDefinitions[configString] - .empty()) - { - result += (result.empty() ? "" : ";") - + this->Internal->CachedLinkInterfaceCompileDefinitions[configString]; + for (std::vector<cmValueWithOrigin>::const_iterator + it = this->Internal->LinkInterfacePropertyEntries.begin(), + end = this->Internal->LinkInterfacePropertyEntries.end(); + it != end; ++it) + { + { + cmGeneratorExpression ge(lfbt); + cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = + ge.Parse(it->Value); + std::string targetResult = cge->Evaluate(this->Makefile, config, + false, this, 0, 0); + if (!this->Makefile->FindTargetToUse(targetResult.c_str())) + { + continue; + } + } + std::string defsGenex = "$<TARGET_PROPERTY:" + + it->Value + ",INTERFACE_COMPILE_DEFINITIONS>"; + if (cmGeneratorExpression::Find(it->Value) != std::string::npos) + { + // Because it->Value is a generator expression, ensure that it + // evaluates to the non-empty string before being used in the + // TARGET_PROPERTY expression. + defsGenex = "$<$<BOOL:" + it->Value + ">:" + defsGenex + ">"; + } + cmGeneratorExpression ge(it->Backtrace); + cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse( + defsGenex); + + this->Internal + ->CachedLinkInterfaceCompileDefinitionsEntries[configString].push_back( + new cmTargetInternals::TargetPropertyEntry(cge, + it->Value)); + } + if (config) + { + std::string configPropName = "COMPILE_DEFINITIONS_" + + cmSystemTools::UpperCase(config); + const char *configProp = this->GetProperty(configPropName.c_str()); + std::string defsString = (configProp ? configProp : ""); + + cmGeneratorExpression ge(lfbt); + cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = + ge.Parse(defsString); + this->Internal + ->CachedLinkInterfaceCompileDefinitionsEntries[configString].push_back( + new cmTargetInternals::TargetPropertyEntry(cge)); + } + } + processCompileDefinitions(this, + this->Internal->CachedLinkInterfaceCompileDefinitionsEntries[configString], + list, + uniqueOptions, + &dagChecker, + config, + debugDefines); + if (!this->Makefile->IsGeneratingBuildSystem()) { - this->Internal->CachedLinkInterfaceCompileDefinitions[configString] = ""; + deleteAndClear(this->Internal + ->CachedLinkInterfaceCompileDefinitionsEntries); } else { this->Internal->CacheLinkInterfaceCompileDefinitionsDone[configString] = true; } - - return result; } //---------------------------------------------------------------------------- @@ -3528,6 +3649,29 @@ static void cmTargetCheckLINK_INTERFACE_LIBRARIES( } //---------------------------------------------------------------------------- +static void cmTargetCheckINTERFACE_LINK_LIBRARIES(const char* value, + cmMakefile* context) +{ + // Look for link-type keywords in the value. + static cmsys::RegularExpression + keys("(^|;)(debug|optimized|general)(;|$)"); + if(!keys.find(value)) + { + return; + } + + // Report an error. + cmOStringStream e; + + e << "Property INTERFACE_LINK_LIBRARIES may not contain link-type " + "keyword \"" << keys.match(2) << "\". The INTERFACE_LINK_LIBRARIES " + "property may contain configuration-sensitive generator-expressions " + "which may be used to specify per-configuration rules."; + + context->IssueMessage(cmake::FATAL_ERROR, e.str()); +} + +//---------------------------------------------------------------------------- void cmTarget::CheckProperty(const char* prop, cmMakefile* context) { // Certain properties need checking. @@ -3545,6 +3689,13 @@ void cmTarget::CheckProperty(const char* prop, cmMakefile* context) cmTargetCheckLINK_INTERFACE_LIBRARIES(prop, value, context, true); } } + if(strncmp(prop, "INTERFACE_LINK_LIBRARIES", 24) == 0) + { + if(const char* value = this->GetProperty(prop)) + { + cmTargetCheckINTERFACE_LINK_LIBRARIES(value, context); + } + } } //---------------------------------------------------------------------------- @@ -3839,6 +3990,24 @@ const char *cmTarget::GetProperty(const char* prop, } return output.c_str(); } + if(strcmp(prop,"COMPILE_DEFINITIONS") == 0) + { + static std::string output; + output = ""; + std::string sep; + typedef cmTargetInternals::TargetPropertyEntry + TargetPropertyEntry; + for (std::vector<TargetPropertyEntry*>::const_iterator + it = this->Internal->CompileDefinitionsEntries.begin(), + end = this->Internal->CompileDefinitionsEntries.end(); + it != end; ++it) + { + output += sep; + output += (*it)->ge->GetInput(); + sep = ";"; + } + return output.c_str(); + } if (strcmp(prop,"IMPORTED") == 0) { @@ -5880,11 +6049,16 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config, // Get the link interface. { - std::string linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES"; - linkProp += suffix; - + std::string linkProp = "INTERFACE_LINK_LIBRARIES"; const char *propertyLibs = this->GetProperty(linkProp.c_str()); + if (!propertyLibs) + { + linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES"; + linkProp += suffix; + propertyLibs = this->GetProperty(linkProp.c_str()); + } + if(!propertyLibs) { linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES"; @@ -6002,6 +6176,48 @@ cmTarget::LinkInterface const* cmTarget::GetLinkInterface(const char* config, } //---------------------------------------------------------------------------- +void cmTarget::GetTransitivePropertyLinkLibraries( + const char* config, + cmTarget *headTarget, + std::vector<std::string> &libs) +{ + cmTarget::LinkInterface const* iface = this->GetLinkInterface(config, + headTarget); + if (!iface) + { + return; + } + if(this->GetType() != STATIC_LIBRARY + || this->GetPolicyStatusCMP0022() == cmPolicies::WARN + || this->GetPolicyStatusCMP0022() == cmPolicies::OLD) + { + libs = iface->Libraries; + return; + } + + const char* linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; + const char* interfaceLibs = this->GetProperty(linkIfaceProp); + + if (!interfaceLibs) + { + return; + } + + // The interface libraries have been explicitly set. + cmListFileBacktrace lfbt; + cmGeneratorExpression ge(lfbt); + cmGeneratorExpressionDAGChecker dagChecker(lfbt, this->GetName(), + linkIfaceProp, 0, 0); + dagChecker.SetTransitivePropertiesOnly(); + cmSystemTools::ExpandListArgument(ge.Parse(interfaceLibs)->Evaluate( + this->Makefile, + config, + false, + headTarget, + this, &dagChecker), libs); +} + +//---------------------------------------------------------------------------- bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, cmTarget *headTarget) { @@ -6019,6 +6235,8 @@ 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; + const char* newExplicitLibraries = + this->GetProperty("INTERFACE_LINK_LIBRARIES"); std::string linkIfaceProp; if(this->GetType() == cmTarget::SHARED_LIBRARY || this->IsExecutableWithExports()) @@ -6034,6 +6252,81 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, linkIfaceProp = "LINK_INTERFACE_LIBRARIES"; explicitLibraries = this->GetProperty(linkIfaceProp.c_str()); } + if (newExplicitLibraries + && (!explicitLibraries || + (explicitLibraries + && strcmp(newExplicitLibraries, explicitLibraries) != 0))) + { + switch(this->GetPolicyStatusCMP0022()) + { + case cmPolicies::WARN: + { + cmOStringStream w; + w << (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0022)) << "\n" + << "Target \"" << this->GetName() << "\" has a " + "INTERFACE_LINK_LIBRARIES property which differs from its " + << linkIfaceProp << " properties."; + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + } + // Fall through + case cmPolicies::OLD: + break; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + explicitLibraries = newExplicitLibraries; + linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; + break; + } + } + } + else if(this->GetType() == cmTarget::STATIC_LIBRARY) + { + if (newExplicitLibraries) + { + cmListFileBacktrace lfbt; + cmGeneratorExpression ge(lfbt); + cmGeneratorExpressionDAGChecker dagChecker(lfbt, this->GetName(), + "INTERFACE_LINK_LIBRARIES", 0, 0); + std::vector<std::string> ifaceLibs; + cmSystemTools::ExpandListArgument( + ge.Parse(newExplicitLibraries)->Evaluate( + this->Makefile, + config, + false, + headTarget, + this, &dagChecker), ifaceLibs); + LinkImplementation const* impl = this->GetLinkImplementation(config, + headTarget); + if (ifaceLibs != impl->Libraries) + { + switch(this->GetPolicyStatusCMP0022()) + { + case cmPolicies::WARN: + { + cmOStringStream w; + w << (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0022)) << "\n" + << "Static library target \"" << this->GetName() << "\" has a " + "INTERFACE_LINK_LIBRARIES property. This should be preferred " + "as the source of the link interface for this library. " + "Ignoring the property and using the link implementation " + "as the link interface instead."; + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + } + // Fall through + case cmPolicies::OLD: + break; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + explicitLibraries = newExplicitLibraries; + linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; + break; + } + } + } } // There is no implicit link interface for executables or modules @@ -6097,7 +6390,11 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, } } } - else + else if (this->GetPolicyStatusCMP0022() == cmPolicies::WARN + || this->GetPolicyStatusCMP0022() == cmPolicies::OLD) + // The implementation shouldn't be the interface if CMP0022 is NEW. That + // way, the LINK_LIBRARIES property can be set directly without having to + // empty the INTERFACE_LINK_LIBRARIES { // The link implementation is the default link interface. LinkImplementation const* impl = this->GetLinkImplementation(config, @@ -6564,6 +6861,7 @@ cmTargetInternalPointer::~cmTargetInternalPointer() { deleteAndClear(this->Pointer->IncludeDirectoriesEntries); deleteAndClear(this->Pointer->CompileOptionsEntries); + deleteAndClear(this->Pointer->CompileDefinitionsEntries); delete this->Pointer; } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 3bc0ab2..6d27d52 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -19,6 +19,14 @@ #include <cmsys/auto_ptr.hxx> +#define CM_FOR_EACH_TARGET_POLICY(F) \ + F(CMP0003) \ + F(CMP0004) \ + F(CMP0008) \ + F(CMP0020) \ + F(CMP0021) \ + F(CMP0022) + class cmake; class cmMakefile; class cmSourceFile; @@ -91,25 +99,13 @@ public: void SetMakefile(cmMakefile *mf); cmMakefile *GetMakefile() const { return this->Makefile;}; - /** Get the status of policy CMP0003 when the target was created. */ - cmPolicies::PolicyStatus GetPolicyStatusCMP0003() const - { return this->PolicyStatusCMP0003; } - - /** Get the status of policy CMP0004 when the target was created. */ - cmPolicies::PolicyStatus GetPolicyStatusCMP0004() const - { return this->PolicyStatusCMP0004; } - - /** Get the status of policy CMP0008 when the target was created. */ - cmPolicies::PolicyStatus GetPolicyStatusCMP0008() const - { return this->PolicyStatusCMP0008; } +#define DECLARE_TARGET_POLICY(POLICY) \ + cmPolicies::PolicyStatus GetPolicyStatus ## POLICY () const \ + { return this->PolicyStatus ## POLICY; } - /** Get the status of policy CMP0020 when the target was created. */ - cmPolicies::PolicyStatus GetPolicyStatusCMP0020() const - { return this->PolicyStatusCMP0020; } + CM_FOR_EACH_TARGET_POLICY(DECLARE_TARGET_POLICY) - /** Get the status of policy CMP0021 when the target was created. */ - cmPolicies::PolicyStatus GetPolicyStatusCMP0021() const - { return this->PolicyStatusCMP0021; } +#undef DECLARE_TARGET_POLICY /** * Get the list of the custom commands for this target @@ -276,6 +272,9 @@ public: if the target cannot be linked. */ LinkInterface const* GetLinkInterface(const char* config, cmTarget *headTarget); + void GetTransitivePropertyLinkLibraries(const char* config, + cmTarget *headTarget, + std::vector<std::string> &libs); /** The link implementation specifies the direct library dependencies needed by the object files of the target. */ @@ -442,7 +441,8 @@ public: If no macro should be defined null is returned. */ const char* GetExportMacro(); - std::string GetCompileDefinitions(const char *config); + void GetCompileDefinitions(std::vector<std::string> &result, + const char *config); // Compute the set of languages compiled by the target. This is // computed every time it is called because the languages can change @@ -513,6 +513,8 @@ public: bool before = false); void InsertCompileOption(const cmValueWithOrigin &entry, bool before = false); + void InsertCompileDefinition(const cmValueWithOrigin &entry, + bool before = false); void AppendBuildInterfaceIncludes(); @@ -649,6 +651,7 @@ private: bool IsImportedTarget; bool DebugIncludesDone; bool DebugCompileOptionsDone; + bool DebugCompileDefinitionsDone; mutable std::set<std::string> LinkImplicitNullProperties; bool BuildInterfaceIncludesAppended; @@ -687,11 +690,12 @@ private: cmMakefile* Makefile; // Policy status recorded when target was created. - cmPolicies::PolicyStatus PolicyStatusCMP0003; - cmPolicies::PolicyStatus PolicyStatusCMP0004; - cmPolicies::PolicyStatus PolicyStatusCMP0008; - cmPolicies::PolicyStatus PolicyStatusCMP0020; - cmPolicies::PolicyStatus PolicyStatusCMP0021; +#define TARGET_POLICY_MEMBER(POLICY) \ + cmPolicies::PolicyStatus PolicyStatus ## POLICY; + + CM_FOR_EACH_TARGET_POLICY(TARGET_POLICY_MEMBER) + +#undef TARGET_POLICY_MEMBER // Internal representation details. friend class cmTargetInternals; diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index b7b7691..c5f490e 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -224,12 +224,17 @@ bool cmTargetLinkLibrariesCommand cmSystemTools::SetFatalErrorOccured(); } + const cmPolicies::PolicyStatus policy22Status + = this->Target->GetPolicyStatusCMP0022(); + // If any of the LINK_ options were given, make sure the // LINK_INTERFACE_LIBRARIES target property exists. // Use of any of the new keywords implies awareness of // this property. And if no libraries are named, it should // result in an empty link interface. - if(this->CurrentProcessingState != ProcessingLinkLibraries && + if((policy22Status == cmPolicies::OLD || + policy22Status == cmPolicies::WARN) && + this->CurrentProcessingState != ProcessingLinkLibraries && !this->Target->GetProperty("LINK_INTERFACE_LIBRARIES")) { this->Target->SetProperty("LINK_INTERFACE_LIBRARIES", ""); @@ -263,11 +268,30 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib, ->AddLinkLibraryForTarget(this->Target->GetName(), lib, llt); if (this->CurrentProcessingState != ProcessingPublicInterface) { + if (this->Target->GetType() == cmTarget::STATIC_LIBRARY) + { + this->Target->AppendProperty("INTERFACE_LINK_LIBRARIES", + ("$<LINK_ONLY:" + + this->Target->GetDebugGeneratorExpressions(lib, llt) + + ">").c_str()); + } // Not LINK_INTERFACE_LIBRARIES or LINK_PUBLIC, do not add to interface. return; } } + this->Target->AppendProperty("INTERFACE_LINK_LIBRARIES", + this->Target->GetDebugGeneratorExpressions(lib, llt).c_str()); + + const cmPolicies::PolicyStatus policy22Status + = this->Target->GetPolicyStatusCMP0022(); + + if (policy22Status != cmPolicies::OLD + && policy22Status != cmPolicies::WARN) + { + return; + } + // Get the list of configurations considered to be DEBUG. std::vector<std::string> const& debugConfigs = this->Makefile->GetCMakeInstance()->GetDebugConfigs(); diff --git a/Source/cmTargetLinkLibrariesCommand.h b/Source/cmTargetLinkLibrariesCommand.h index c683016..ca651d0 100644 --- a/Source/cmTargetLinkLibrariesCommand.h +++ b/Source/cmTargetLinkLibrariesCommand.h @@ -92,7 +92,7 @@ public: "When this target is linked into another target then the libraries " "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 " + "See the INTERFACE_LINK_LIBRARIES target property to override the " "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." @@ -112,14 +112,19 @@ public: " target_link_libraries(<target> LINK_INTERFACE_LIBRARIES\n" " [[debug|optimized|general] <lib>] ...)\n" "The LINK_INTERFACE_LIBRARIES mode appends the libraries " - "to the LINK_INTERFACE_LIBRARIES and its per-configuration equivalent " - "target properties instead of using them for linking. " - "Libraries specified as \"debug\" are appended to the " + "to the INTERFACE_LINK_LIBRARIES target property instead of using them " + "for linking. If policy CMP0022 is not NEW, then this mode also " + "appends libraries to the LINK_INTERFACE_LIBRARIES and its " + "per-configuration equivalent. " + "Libraries specified as \"debug\" are wrapped in a generator " + "expression to correspond to debug builds. If policy CMP0022 is not " + "NEW, the libraries are also appended to the " "LINK_INTERFACE_LIBRARIES_DEBUG property (or to the properties " "corresponding to configurations listed in the DEBUG_CONFIGURATIONS " "global property if it is set). " "Libraries specified as \"optimized\" are appended to the " - "LINK_INTERFACE_LIBRARIES property. " + "INTERFACE_LINK_LIBRARIES property. If policy CMP0022 is not NEW, " + "they are also appended to the LINK_INTERFACE_LIBRARIES property. " "Libraries specified as \"general\" (or without any keyword) are " "treated as if specified for both \"debug\" and \"optimized\"." "\n" @@ -131,9 +136,11 @@ public: "The LINK_PUBLIC and LINK_PRIVATE modes can be used to specify both " "the link dependencies and the link interface in one command. " "Libraries and targets following LINK_PUBLIC are linked to, and are " - "made part of the LINK_INTERFACE_LIBRARIES. Libraries and targets " - "following LINK_PRIVATE are linked to, but are not made part of the " - "LINK_INTERFACE_LIBRARIES. " + "made part of the INTERFACE_LINK_LIBRARIES. If policy CMP0022 is not " + "NEW, they are also made part of the LINK_INTERFACE_LIBRARIES. " + "Libraries and targets following LINK_PRIVATE are linked to, but are " + "not made part of the INTERFACE_LINK_LIBRARIES (or " + "LINK_INTERFACE_LIBRARIES)." "\n" "The library dependency graph is normally acyclic (a DAG), but in the " "case of mutually-dependent STATIC libraries CMake allows the graph " diff --git a/Source/cmTryCompileCommand.h b/Source/cmTryCompileCommand.h index 163756d..a20594c 100644 --- a/Source/cmTryCompileCommand.h +++ b/Source/cmTryCompileCommand.h @@ -69,14 +69,14 @@ public: " [COMPILE_DEFINITIONS flags...]\n" " [LINK_LIBRARIES libs...]\n" " [OUTPUT_VARIABLE <var>]\n" - " [COPY_FILE <fileName>])\n" + " [COPY_FILE <fileName> [COPY_FILE_ERROR <var>]])\n" "Try building an executable from one or more source files. " "In this form the user need only supply one or more source files " "that include a definition for 'main'. " "CMake will create a CMakeLists.txt file to build the source(s) " "as an executable. " "Specify COPY_FILE to get a copy of the linked executable at the " - "given fileName." + "given fileName and optionally COPY_FILE_ERROR to capture any error." "\n" "In this version all files in bindir/CMakeFiles/CMakeTmp " "will be cleaned automatically. For debugging, --debug-trycompile can " diff --git a/Source/cmVS10LinkFlagTable.h b/Source/cmVS10LinkFlagTable.h index 64febbb..5d15620 100644 --- a/Source/cmVS10LinkFlagTable.h +++ b/Source/cmVS10LinkFlagTable.h @@ -201,7 +201,7 @@ static cmVS7FlagTable cmVS10LinkFlagTable[] = cmVS7FlagTable::UserValueRequired}, {"GenerateMapFile", "MAP", "", "true", cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue}, - {"MapFileName", "MAP", "Generate Map File", "", + {"MapFileName", "MAP:", "Generate Map File", "", cmVS7FlagTable::UserValueRequired}, //String List Properties diff --git a/Source/cmVS11LinkFlagTable.h b/Source/cmVS11LinkFlagTable.h index ea0d0f0..b4587a8 100644 --- a/Source/cmVS11LinkFlagTable.h +++ b/Source/cmVS11LinkFlagTable.h @@ -227,7 +227,7 @@ static cmVS7FlagTable cmVS11LinkFlagTable[] = cmVS7FlagTable::UserValueRequired}, {"GenerateMapFile", "MAP", "", "true", cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue}, - {"MapFileName", "MAP", "Generate Map File", "", + {"MapFileName", "MAP:", "Generate Map File", "", cmVS7FlagTable::UserValueRequired}, //String List Properties diff --git a/Source/cmVS12LinkFlagTable.h b/Source/cmVS12LinkFlagTable.h index ce32e38..73d450a 100644 --- a/Source/cmVS12LinkFlagTable.h +++ b/Source/cmVS12LinkFlagTable.h @@ -227,7 +227,7 @@ static cmVS7FlagTable cmVS12LinkFlagTable[] = cmVS7FlagTable::UserValueRequired}, {"GenerateMapFile", "MAP", "", "true", cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue}, - {"MapFileName", "MAP", "Generate Map File", "", + {"MapFileName", "MAP:", "Generate Map File", "", cmVS7FlagTable::UserValueRequired}, //String List Properties diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 50f195e..d59de11 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1337,8 +1337,9 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( clOptions.AddFlag("AssemblerListingLocation", asmLocation.c_str()); clOptions.Parse(flags.c_str()); clOptions.Parse(defineFlags.c_str()); - clOptions.AddDefines(this->Target->GetCompileDefinitions( - configName.c_str()).c_str()); + std::vector<std::string> targetDefines; + this->Target->GetCompileDefinitions(targetDefines, configName.c_str()); + clOptions.AddDefines(targetDefines); clOptions.SetVerboseMakefile( this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")); diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 4d5af5e..935b836 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -4261,17 +4261,13 @@ bool SystemTools::IsSubDirectory(const char* cSubdir, const char* cDir) } kwsys_stl::string subdir = cSubdir; kwsys_stl::string dir = cDir; + SystemTools::ConvertToUnixSlashes(subdir); SystemTools::ConvertToUnixSlashes(dir); - kwsys_stl::string path = subdir; - do + if(subdir.size() > dir.size() && subdir[dir.size()] == '/') { - path = SystemTools::GetParentDirectory(path.c_str()); - if(SystemTools::ComparePath(dir.c_str(), path.c_str())) - { - return true; - } + std::string s = subdir.substr(0, dir.size()); + return SystemTools::ComparePath(s.c_str(), dir.c_str()); } - while ( path.size() > dir.size() ); return false; } |